diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 02e37163..8042025e 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -88,8 +88,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : m_DownloadMessageBox(NULL), m_pCancelButton(NULL), m_SuppressAutoConfigWarning(false), - m_BonjourInstall(NULL), - m_BonjourInstallThread(NULL) + m_BonjourInstall(NULL) { setupUi(this); @@ -143,10 +142,6 @@ MainWindow::~MainWindow() if (m_BonjourInstall != NULL) { delete m_BonjourInstall; } - - if (m_BonjourInstallThread != NULL) { - delete m_BonjourInstallThread; - } } void MainWindow::open() @@ -1111,13 +1106,16 @@ void MainWindow::installBonjour() if (m_BonjourInstall == NULL) { m_BonjourInstall = new CommandProcess("msiexec", arguments); } - if (m_BonjourInstallThread == NULL) { - m_BonjourInstallThread = new QThread; - } - m_BonjourInstall->moveToThread(m_BonjourInstallThread); + + QThread* thread = new QThread; connect(m_BonjourInstall, SIGNAL(finished()), this, SLOT(bonjourInstallFinished())); - m_BonjourInstallThread->start(); + connect(m_BonjourInstall, SIGNAL(finished()), thread, SLOT(quit())); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + + m_BonjourInstall->moveToThread(thread); + thread->start(); + QMetaObject::invokeMethod(m_BonjourInstall, "run", Qt::QueuedConnection); m_DownloadMessageBox->hide(); @@ -1184,11 +1182,7 @@ void MainWindow::on_m_pCheckBoxAutoConfig_toggled(bool checked) void MainWindow::bonjourInstallFinished() { - delete m_BonjourInstall; - m_BonjourInstall = NULL; - - delete m_BonjourInstallThread; - m_BonjourInstallThread = NULL; + appendLogNote("Bonjour install finished"); updateZeroconfService(); } diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 9082dc91..e0d74244 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -191,7 +191,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase QMutex m_Mutex; bool m_SuppressAutoConfigWarning; CommandProcess* m_BonjourInstall; - QThread* m_BonjourInstallThread; private slots: void on_m_pCheckBoxAutoConfig_toggled(bool checked);