Track whether setup detection has already been started and avoid running it twice

This makes the code more explicit about avoiding triggering the setup
detection twice. Maybe it fixes
https://github.com/Martchus/syncthingtray/issues/174 but likely it does not
change the behavior (in general).
This commit is contained in:
Martchus 2023-02-15 19:21:48 +01:00
parent 3829b65f85
commit cc2b3365fb
3 changed files with 13 additions and 1 deletions

View File

@ -98,10 +98,15 @@ void SetupDetection::reset()
launcherExitStatus.reset();
launcherError.reset();
launcherOutput.clear();
m_testStarted = false;
}
void SetupDetection::startTest()
{
if (m_testStarted) {
return;
}
m_testStarted = true;
restoreConfig();
initConnection();
connection.reconnect();
@ -141,8 +146,12 @@ void SetupDetection::handleTimeout()
void SetupDetection::checkDone()
{
if (!m_testStarted) {
return;
}
if (isDone()) {
timeout.stop();
m_testStarted = false;
emit done();
}
}

View File

@ -67,6 +67,9 @@ public:
bool timedOut = false;
bool configOk = false;
bool autostartEnabled = false;
private:
bool m_testStarted = false;
};
} // namespace QtGui

View File

@ -532,7 +532,6 @@ void DetectionWizardPage::initializePage()
}
m_setupDetection->reset();
connect(m_setupDetection, &SetupDetection::done, this, &DetectionWizardPage::continueIfDone);
emit completeChanged();
QTimer::singleShot(0, this, &DetectionWizardPage::tryToConnect);
}
@ -591,6 +590,7 @@ void DetectionWizardPage::tryToConnect()
}
// start setup detection tests
connect(m_setupDetection, &SetupDetection::done, this, &DetectionWizardPage::continueIfDone, Qt::QueuedConnection);
m_setupDetection->startTest();
}