mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
added a bunch of disconnect safeguards to ScanModFolders to avoid triggering ASSERT_NEVER(!isRunning()) in Task.cpp
Signed-off-by: dyredhead <danielyentin@gmail.com>
This commit is contained in:
parent
f0d4bba7eb
commit
f5d9e25b26
2 changed files with 44 additions and 4 deletions
|
|
@ -45,19 +45,19 @@ void ScanModFolders::executeTask()
|
|||
auto m_inst = m_parent->instance();
|
||||
|
||||
auto loaders = m_inst->loaderModList();
|
||||
connect(loaders, &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone);
|
||||
connect(loaders, &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone, Qt::UniqueConnection);
|
||||
if (!loaders->update()) {
|
||||
m_modsDone = true;
|
||||
}
|
||||
|
||||
auto cores = m_inst->coreModList();
|
||||
connect(cores, &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone);
|
||||
connect(cores, &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone, Qt::UniqueConnection);
|
||||
if (!cores->update()) {
|
||||
m_coreModsDone = true;
|
||||
}
|
||||
|
||||
auto nils = m_inst->nilModList();
|
||||
connect(nils, &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
|
||||
connect(nils, &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone, Qt::UniqueConnection);
|
||||
if (!nils->update()) {
|
||||
m_nilModsDone = true;
|
||||
}
|
||||
|
|
@ -66,25 +66,63 @@ void ScanModFolders::executeTask()
|
|||
|
||||
void ScanModFolders::modsDone()
|
||||
{
|
||||
qDebug() << "Check done in ScanModFolders modsDone...";
|
||||
if (!isRunning()) {
|
||||
qDebug() << "ScanModFolders::modsDone called but step not running; ignoring.";
|
||||
return;
|
||||
}
|
||||
m_modsDone = true;
|
||||
checkDone();
|
||||
}
|
||||
|
||||
void ScanModFolders::coreModsDone()
|
||||
{
|
||||
qDebug() << "Check done in ScanModFolders coreModsDone...";
|
||||
if (!isRunning()) {
|
||||
qDebug() << "ScanModFolders::coreModsDone called but step not running; "
|
||||
"ignoring.";
|
||||
return;
|
||||
}
|
||||
m_coreModsDone = true;
|
||||
checkDone();
|
||||
}
|
||||
|
||||
void ScanModFolders::nilModsDone()
|
||||
{
|
||||
qDebug() << "Check done in ScanModFolders nilModsDone...";
|
||||
if (!isRunning()) {
|
||||
qDebug() << "ScanModFolders::nilModsDone called but step not running; ignoring.";
|
||||
return;
|
||||
}
|
||||
m_nilModsDone = true;
|
||||
checkDone();
|
||||
}
|
||||
|
||||
void ScanModFolders::checkDone()
|
||||
{
|
||||
qDebug() << "Check done in ScanModFolders...";
|
||||
if (m_modsDone && m_coreModsDone && m_nilModsDone) {
|
||||
// Disconnect model signals before finishing so the finished step doesn't
|
||||
// receive later updateFinished() notifications and try to finish again.
|
||||
auto m_inst = m_parent->instance();
|
||||
if (m_inst) {
|
||||
disconnect(m_inst->loaderModList(), &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone);
|
||||
disconnect(m_inst->coreModList(), &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone);
|
||||
disconnect(m_inst->nilModList(), &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
|
||||
}
|
||||
|
||||
emitSucceeded();
|
||||
}
|
||||
}
|
||||
|
||||
void ScanModFolders::finalize()
|
||||
{
|
||||
auto m_inst = m_parent->instance();
|
||||
if (!m_inst) {
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(m_inst->loaderModList(), &ModFolderModel::updateFinished, this, &ScanModFolders::modsDone);
|
||||
disconnect(m_inst->coreModList(), &ModFolderModel::updateFinished, this, &ScanModFolders::coreModsDone);
|
||||
disconnect(m_inst->nilModList(), &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,12 @@ class ScanModFolders : public LaunchStep {
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit ScanModFolders(LaunchTask* parent) : LaunchStep(parent) {};
|
||||
virtual ~ScanModFolders() {};
|
||||
virtual ~ScanModFolders() = default;
|
||||
|
||||
virtual void executeTask() override;
|
||||
virtual bool canAbort() const override { return false; }
|
||||
virtual void finalize() override;
|
||||
|
||||
private slots:
|
||||
void coreModsDone();
|
||||
void modsDone();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue