From 55576e7f9da9d0e50bee54106968cb7452e0c079 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 6 Nov 2014 17:53:22 -0800 Subject: [PATCH] fix crash in mouse messages while quitting --- interface/src/Application.cpp | 20 ++++++++++++++++---- interface/src/Application.h | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4602bf2db6..a62ce0e209 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -185,7 +185,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _trayIcon(new QSystemTrayIcon(_window)), _lastNackTime(usecTimestampNow()), _lastSendDownstreamAudioStats(usecTimestampNow()), - _isVSyncOn(true) + _isVSyncOn(true), + _aboutToQuit(false) { // read the ApplicationInfo.ini file for Name/Version/Domain information @@ -390,6 +391,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts())); + connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); // check first run... QVariant firstRunValue = _settings->value("firstRun",QVariant(true)); @@ -423,6 +425,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : this->installEventFilter(this); } +void Application::aboutToQuit() { + _aboutToQuit = true; +} + Application::~Application() { qInstallMessageHandler(NULL); @@ -1255,7 +1261,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { showMouse = false; } - _entities.mouseMoveEvent(event, deviceID); + if (!_aboutToQuit) { + _entities.mouseMoveEvent(event, deviceID); + } _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts @@ -1278,7 +1286,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { - _entities.mousePressEvent(event, deviceID); + if (!_aboutToQuit) { + _entities.mousePressEvent(event, deviceID); + } _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts @@ -1319,7 +1329,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { - _entities.mouseReleaseEvent(event, deviceID); + if (!_aboutToQuit) { + _entities.mouseReleaseEvent(event, deviceID); + } _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts diff --git a/interface/src/Application.h b/interface/src/Application.h index 115dd45833..eee2581e2e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -306,6 +306,7 @@ public: unsigned int getRenderTargetFramerate() const; bool isVSyncOn() const; bool isVSyncEditable() const; + bool isAboutToQuit() const { return _aboutToQuit; } void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine); @@ -380,6 +381,7 @@ private slots: void clearDomainOctreeDetails(); void timer(); void idle(); + void aboutToQuit(); void connectedToDomain(const QString& hostname); @@ -626,6 +628,8 @@ private: quint64 _lastSendDownstreamAudioStats; bool _isVSyncOn; + + bool _aboutToQuit; }; #endif // hifi_Application_h