From 4cf1ab8a25ba67fbd0f2d0a3c8f18ea6c2f38f66 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 8 Aug 2018 17:20:16 +0100 Subject: [PATCH] #6338 Refactor auto restart logic, fixed debug level check, added some debug logging --- src/gui/src/MainWindow.cpp | 59 ++++++++++++++++++------------------ src/gui/src/ServerConfig.cpp | 2 +- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 53719220..624d71ba 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -62,6 +62,8 @@ static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*. static const char* tlsVersion = "TLS 1.2"; static const char* tlsCheckString = "network encryption protocol: TLSv1.2"; +static const int debugLogLevel = 1; + static const char* synergyIconFiles[] = { ":/res/icons/16x16/synergy-disconnected.png", @@ -408,7 +410,7 @@ void MainWindow::appendLogInfo(const QString& text) } void MainWindow::appendLogDebug(const QString& text) { - if (appConfig().logLevel() >= 4) { + if (appConfig().logLevel() >= debugLogLevel) { appendLogRaw(getTimeStamp() + " DEBUG: " + text); } } @@ -1285,36 +1287,36 @@ void MainWindow::on_m_pActionSettings_triggered() void MainWindow::autoAddScreen(const QString name) { - if (!m_ServerConfig.ignoreAutoConfigClient()) { + if (m_ServerConfig.ignoreAutoConfigClient()) { + appendLogDebug(QString("ignoring zeroconf screen: %1").arg(name)); + return; + } + #ifndef SYNERGY_ENTERPRISE - if (m_ActivationDialogRunning) { - // TODO: refactor this code - // add this screen to the pending list and check this list until - // users finish activation dialog - m_PendingClientNames.append(name); - return; - } + if (m_ActivationDialogRunning) { + // TODO: refactor this code + // add this screen to the pending list and check this list until + // users finish activation dialog + m_PendingClientNames.append(name); + return; + } #endif - int r = m_ServerConfig.autoAddScreen(name); - if (r != kAutoAddScreenOk) { - switch (r) { - case kAutoAddScreenManualServer: - showConfigureServer( - tr("Please add the server (%1) to the grid.") - .arg(appConfig().screenName())); - break; + int r = m_ServerConfig.autoAddScreen(name); + if (r != kAutoAddScreenOk) { + switch (r) { + case kAutoAddScreenManualServer: + showConfigureServer( + tr("Please add the server (%1) to the grid.") + .arg(appConfig().screenName())); + break; - case kAutoAddScreenManualClient: - showConfigureServer( - tr("Please drag the new client screen (%1) " - "to the desired position on the grid.") - .arg(name)); - break; - } - } - else { - restartSynergy(); + case kAutoAddScreenManualClient: + showConfigureServer( + tr("Please drag the new client screen (%1) " + "to the desired position on the grid.") + .arg(name)); + break; } } } @@ -1362,9 +1364,6 @@ int MainWindow::raiseActivationDialog() m_PendingClientNames.clear(); } - if (result == QDialog::Accepted) { - restartSynergy(); - } return result; } #endif diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index bddb1444..fd821e5a 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -303,7 +303,7 @@ int ServerConfig::autoAddScreen(const QString name) } } if (findScreenName(name, targetIndex)) { - // already exists. + m_pMainWindow->appendLogDebug(QString("ignoring screen already in config: %1").arg(name)); return kAutoAddScreenIgnore; }