From: Alex Montgomery Date: Tue, 10 May 2011 22:19:12 +0000 (+0100) Subject: - fixed XRun on exit, pass CFLAGS to QMAKE. X-Git-Tag: v4~6 X-Git-Url: https://repo.or.cz/w/jackctlmmc.git/commitdiff_plain/aeaa54f3a769447604e5375a133c1489d07cbac2 - fixed XRun on exit, pass CFLAGS to QMAKE. --- diff --git a/qt/src/mainWindow.cpp b/qt/src/mainWindow.cpp index d2f1e2d..84a1ab4 100644 --- a/qt/src/mainWindow.cpp +++ b/qt/src/mainWindow.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "mainWindow.h" #include "validator.h" @@ -85,11 +86,6 @@ bool MainWindow::init(int argc, char *argv[]) return succeeded; } -MainWindow::~MainWindow() -{ - cleanup_globals(); -} - void MainWindow::on_actionQuit_triggered() { close(); @@ -365,3 +361,16 @@ void MainWindow::setDefaultSettings() m_settings.jitterTolerance = 50; m_settings.verbose = false; } + +void MainWindow::closeEvent(QCloseEvent* event) +{ + // separating the clean-up into the close event (instead of the destructor) prevents an XRun on shutdown + if (m_sequencerThread) + { + m_sequencerThread->die(); // die() calls deleteLater and ensures the thread is cleaned up once the listen loop ends + m_sequencerThread->wait(); + } + + cleanup_globals(); + event->accept(); +} diff --git a/qt/src/mainWindow.h b/qt/src/mainWindow.h index 3d3f130..c1bd55e 100644 --- a/qt/src/mainWindow.h +++ b/qt/src/mainWindow.h @@ -41,7 +41,6 @@ class MainWindow : public QMainWindow, public Ui::QjackMMC public: MainWindow(); bool init(int argc, char *argv[]); - virtual ~MainWindow(); public slots: // these are autoconnected by virtue of their naming convention. QT4 voodoo @@ -67,6 +66,9 @@ class MainWindow : public QMainWindow, public Ui::QjackMMC bool initSound(int argc, char *argv[]); void loadConfig(QFile& loadFile); void setDefaultSettings(); + + // QT reimplementations + void closeEvent(QCloseEvent* event); QPointer m_sequencerThread; MidiSettings m_settings; //< shared between threads, Always lock m_settingsMutex when accessing! diff --git a/qt/src/sequencerThread.cpp b/qt/src/sequencerThread.cpp index 41ba4c1..b3d9b5b 100644 --- a/qt/src/sequencerThread.cpp +++ b/qt/src/sequencerThread.cpp @@ -23,7 +23,7 @@ #include SequencerThread::SequencerThread(QObject* parent, MidiSettings* settings, QMutex* settingsMutex) - : QThread(parent), m_settings(settings), m_settingsMutex(settingsMutex), m_shouldExit(false) + : QThread(parent), m_settings(settings), m_settingsMutex(settingsMutex), m_shouldExit(0) { } @@ -59,5 +59,5 @@ void SequencerThread::run () void SequencerThread::die() { - m_shouldExit = true; + m_shouldExit = 1; } diff --git a/qt/src/sequencerThread.h b/qt/src/sequencerThread.h index 41b6e3f..b539a8d 100644 --- a/qt/src/sequencerThread.h +++ b/qt/src/sequencerThread.h @@ -19,6 +19,8 @@ ***************************************************************************/ #include +#include + class QMutex; extern "C" { @@ -41,5 +43,5 @@ class SequencerThread : public QThread MidiSettings* m_settings; QMutex* m_settingsMutex; - bool m_shouldExit; + QAtomicInt m_shouldExit; //< atomic int used as bool }; diff --git a/qt/src/src.pro.in b/qt/src/src.pro.in index d953943..cf73c49 100644 --- a/qt/src/src.pro.in +++ b/qt/src/src.pro.in @@ -23,3 +23,6 @@ PKGCONFIG += @ac_pkgs@ TARGET = qjackmmc DESTDIR = ../../ QT += gui + +QMAKE_CFLAGS += $$(CFLAGS) +QMAKE_CXXFLAGS += $$(CFLAGS)