From 4452f1411490da9a08f82f8b8439b7f4412320de Mon Sep 17 00:00:00 2001 From: Xinyu Hou Date: Fri, 28 Nov 2014 12:57:57 +0000 Subject: [PATCH] Updated zeroconf after Bonjour is installed #4235 --- src/gui/src/CommandProcess.cpp | 1 + src/gui/src/CommandProcess.h | 3 +++ src/gui/src/MainWindow.cpp | 40 ++++++++++++++++++++++++++++------ src/gui/src/MainWindow.h | 4 ++++ 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/gui/src/CommandProcess.cpp b/src/gui/src/CommandProcess.cpp index b3cda409..72cd44ae 100644 --- a/src/gui/src/CommandProcess.cpp +++ b/src/gui/src/CommandProcess.cpp @@ -30,4 +30,5 @@ void CommandProcess::run() QProcess process; process.start(m_Command, m_Arguments); process.waitForFinished(); + emit finished(); } diff --git a/src/gui/src/CommandProcess.h b/src/gui/src/CommandProcess.h index ac81701c..3ed935b5 100644 --- a/src/gui/src/CommandProcess.h +++ b/src/gui/src/CommandProcess.h @@ -27,6 +27,9 @@ class CommandProcess : public QObject public: CommandProcess(QString cmd, QStringList arguments); +signals: + void finished(); + public slots: void run(); diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 6afb4682..02e37163 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -87,7 +87,9 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : m_pDataDownloader(NULL), m_DownloadMessageBox(NULL), m_pCancelButton(NULL), - m_SuppressAutoConfigWarning(false) + m_SuppressAutoConfigWarning(false), + m_BonjourInstall(NULL), + m_BonjourInstallThread(NULL) { setupUi(this); @@ -137,6 +139,14 @@ MainWindow::~MainWindow() if (m_DownloadMessageBox != NULL) { delete m_DownloadMessageBox; } + + if (m_BonjourInstall != NULL) { + delete m_BonjourInstall; + } + + if (m_BonjourInstallThread != NULL) { + delete m_BonjourInstallThread; + } } void MainWindow::open() @@ -1098,12 +1108,17 @@ void MainWindow::installBonjour() QString winFilename = QDir::toNativeSeparators(filename); arguments.append(winFilename); arguments.append("/passive"); - CommandProcess* cp = new CommandProcess("msiexec", arguments); - QThread* thread = new QThread; - cp->moveToThread(thread); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - thread->start(); - QMetaObject::invokeMethod(cp, "run", Qt::QueuedConnection); + if (m_BonjourInstall == NULL) { + m_BonjourInstall = new CommandProcess("msiexec", arguments); + } + if (m_BonjourInstallThread == NULL) { + m_BonjourInstallThread = new QThread; + } + m_BonjourInstall->moveToThread(m_BonjourInstallThread); + connect(m_BonjourInstall, SIGNAL(finished()), this, + SLOT(bonjourInstallFinished())); + m_BonjourInstallThread->start(); + QMetaObject::invokeMethod(m_BonjourInstall, "run", Qt::QueuedConnection); m_DownloadMessageBox->hide(); #endif @@ -1166,3 +1181,14 @@ void MainWindow::on_m_pCheckBoxAutoConfig_toggled(bool checked) m_pComboServerList->hide(); } } + +void MainWindow::bonjourInstallFinished() +{ + delete m_BonjourInstall; + m_BonjourInstall = NULL; + + delete m_BonjourInstallThread; + m_BonjourInstallThread = NULL; + + updateZeroconfService(); +} diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index c16b5db2..9082dc91 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -55,6 +55,7 @@ class QSynergyApplication; class SetupWizard; class ZeroconfService; class DataDownloader; +class CommandProcess; class MainWindow : public QMainWindow, public Ui::MainWindowBase { @@ -134,6 +135,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase void logOutput(); void logError(); void updateFound(const QString& version); + void bonjourInstallFinished(); protected: QSettings& settings() { return m_Settings; } @@ -188,6 +190,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase QAbstractButton* m_pCancelButton; QMutex m_Mutex; bool m_SuppressAutoConfigWarning; + CommandProcess* m_BonjourInstall; + QThread* m_BonjourInstallThread; private slots: void on_m_pCheckBoxAutoConfig_toggled(bool checked);