Merge pull request #6477 from symless/v1-issue-6471-retry-loop

Stopped gui locking into retry loop
This commit is contained in:
Jnewbon 2019-04-30 15:51:45 +01:00 committed by GitHub
commit 0ef70ac2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 8 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
@ -442,7 +443,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);
@ -712,6 +713,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)
{ {
@ -935,7 +946,9 @@ void MainWindow::synergyFinished(int exitCode, QProcess::ExitStatus)
} }
if (m_ExpectedRunningState == kStarted) { if (m_ExpectedRunningState == kStarted) {
QTimer::singleShot(1000, this, SLOT(startSynergy()));
setSynergyState(synergyPendingRetry);
QTimer::singleShot(1000, this, SLOT(retryStart()));
appendLogInfo(QString("detected process not running, auto restarting")); appendLogInfo(QString("detected process not running, auto restarting"));
} }
else { else {
@ -955,7 +968,7 @@ void MainWindow::setSynergyState(qSynergyState state)
if (synergyState() == state) if (synergyState() == state)
return; return;
if ((state == synergyConnected) || (state == synergyConnecting) || (state == synergyListening)) if ((state == synergyConnected) || (state == synergyConnecting) || (state == synergyListening) || (state == synergyPendingRetry))
{ {
disconnect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger())); disconnect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
connect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, SLOT(trigger())); connect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, SLOT(trigger()));
@ -999,6 +1012,9 @@ void MainWindow::setSynergyState(qSynergyState state)
case synergyConnecting: case synergyConnecting:
setStatus(tr("Synergy is starting...")); setStatus(tr("Synergy is starting..."));
break; break;
case synergyPendingRetry:
setStatus(tr("There was an error, retrying..."));
break;
case synergyDisconnected: case synergyDisconnected:
setStatus(tr("Synergy is not running")); setStatus(tr("Synergy is not running"));
break; break;

View File

@ -73,7 +73,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
synergyDisconnected, synergyDisconnected,
synergyConnecting, synergyConnecting,
synergyConnected, synergyConnected,
synergyListening synergyListening,
synergyPendingRetry
}; };
enum qSynergyType enum qSynergyType
@ -138,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);