fix crash in mouse messages while quitting

This commit is contained in:
ZappoMan 2014-11-06 17:53:22 -08:00
parent c1385a9c35
commit 55576e7f9d
2 changed files with 20 additions and 4 deletions

View file

@ -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

View file

@ -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