#6471 Fixed ability to stop the retry loop when synergy fails to start

This commit is contained in:
Jamie Newbon 2019-04-30 13:12:17 +01:00
parent e29ee68ff9
commit 7f4ca77444
No known key found for this signature in database
GPG Key ID: 9618C9BB2FF44DB5
2 changed files with 23 additions and 7 deletions

View File

@ -66,10 +66,11 @@ static const int debugLogLevel = 1;
static const char* synergyIconFiles[] = static const char* synergyIconFiles[] =
{ {
":/res/icons/16x16/synergy-disconnected.png", ":/res/icons/16x16/synergy-disconnected.png", //synergyDisconnected
":/res/icons/16x16/synergy-disconnected.png", ":/res/icons/16x16/synergy-disconnected.png", //synergyConnecting
":/res/icons/16x16/synergy-connected.png", ":/res/icons/16x16/synergy-connected.png", //synergyConnected
":/res/icons/16x16/synergy-transfering.png" ":/res/icons/16x16/synergy-transfering.png", //synergyListening
":/res/icons/16x16/synergy-disconnected.png" //synergyPendingRetry
}; };
#ifdef SYNERGY_ENTERPRISE #ifdef SYNERGY_ENTERPRISE
@ -441,7 +442,7 @@ void MainWindow::appendLogRaw(const QString& text)
void MainWindow::updateFromLogLine(const QString &line) void MainWindow::updateFromLogLine(const QString &line)
{ {
// TODO: this code makes Andrew cry // TODO: This shouldn't be updating from log needs a better way of doing this
checkConnected(line); checkConnected(line);
checkFingerprint(line); checkFingerprint(line);
checkSecureSocket(line); checkSecureSocket(line);
@ -711,6 +712,16 @@ void MainWindow::startSynergy()
} }
} }
void MainWindow::retryStart()
{
//This function is only called after a failed start
//Only start synergy if the current state is pending retry
if (m_SynergyState == synergyPendingRetry)
{
startSynergy();
}
}
void void
MainWindow::sslToggled (bool enabled) MainWindow::sslToggled (bool enabled)
{ {
@ -934,9 +945,10 @@ void MainWindow::synergyFinished(int exitCode, QProcess::ExitStatus)
} }
if (m_ExpectedRunningState == kStarted) { if (m_ExpectedRunningState == kStarted) {
QTimer::singleShot(1000, this, SLOT(startSynergy()));
appendLogInfo(QString("detected process not running, auto restarting"));
setSynergyState(synergyPendingRetry); setSynergyState(synergyPendingRetry);
QTimer::singleShot(1000, this, SLOT(retryStart()));
appendLogInfo(QString("detected process not running, auto restarting"));
} }
else { else {
setSynergyState(synergyDisconnected); setSynergyState(synergyDisconnected);
@ -998,6 +1010,9 @@ void MainWindow::setSynergyState(qSynergyState state)
} }
case synergyConnecting: case synergyConnecting:
setStatus(tr("Synergy is starting...")); setStatus(tr("Synergy is starting..."));
break;
case synergyPendingRetry:
setStatus(tr("There was an error, retrying..."));
break; break;
case synergyDisconnected: case synergyDisconnected:
setStatus(tr("Synergy is not running")); setStatus(tr("Synergy is not running"));

View File

@ -139,6 +139,7 @@ public slots:
void appendLogDebug(const QString& text); void appendLogDebug(const QString& text);
void appendLogError(const QString& text); void appendLogError(const QString& text);
void startSynergy(); void startSynergy();
void retryStart(); // If the connection failed this will retry a startSynergy
protected slots: protected slots:
void sslToggled(bool enabled); void sslToggled(bool enabled);