From bceab4ead90a99147be0c6a08929281713423ef6 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 6 Nov 2014 17:25:49 -0800 Subject: [PATCH 1/3] clear all octree related state when disconnecting from a domain --- interface/src/Application.cpp | 17 ++++++++++++++--- interface/src/Application.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 38a0682e20..4602bf2db6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -255,6 +255,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&))); connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle())); connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle())); + connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived); connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag); @@ -3565,9 +3566,8 @@ void Application::changeDomainHostname(const QString &newDomainHostname) { } } -void Application::domainChanged(const QString& domainHostname) { - updateWindowTitle(); - +void Application::clearDomainOctreeDetails() { + qDebug() << "Clearing domain octree details..."; // reset the environment so that we don't erroneously end up with multiple _environment.resetToDefault(); @@ -3576,7 +3576,13 @@ void Application::domainChanged(const QString& domainHostname) { _voxelServerJurisdictions.clear(); _voxelServerJurisdictions.unlock(); + _entityServerJurisdictions.lockForWrite(); + _entityServerJurisdictions.clear(); + _entityServerJurisdictions.unlock(); + + _octreeSceneStatsLock.lockForWrite(); _octreeServerSceneStats.clear(); + _octreeSceneStatsLock.unlock(); // reset the model renderer _entities.clear(); @@ -3585,6 +3591,11 @@ void Application::domainChanged(const QString& domainHostname) { _voxels.killLocalVoxels(); } +void Application::domainChanged(const QString& domainHostname) { + updateWindowTitle(); + clearDomainOctreeDetails(); +} + void Application::connectedToDomain(const QString& hostname) { AccountManager& accountManager = AccountManager::getInstance(); const QUuid& domainID = NodeList::getInstance()->getDomainHandler().getUUID(); diff --git a/interface/src/Application.h b/interface/src/Application.h index d92333058f..115dd45833 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -377,6 +377,7 @@ public slots: void resetSensors(); private slots: + void clearDomainOctreeDetails(); void timer(); void idle(); From c1385a9c354003773b79b58c71925fc0cf4b41fa Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 6 Nov 2014 17:41:55 -0800 Subject: [PATCH 2/3] fix random crash on checkEnterLeaveEntities --- interface/src/entities/EntityTreeRenderer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/entities/EntityTreeRenderer.cpp b/interface/src/entities/EntityTreeRenderer.cpp index e447c703fb..46406e9f5e 100644 --- a/interface/src/entities/EntityTreeRenderer.cpp +++ b/interface/src/entities/EntityTreeRenderer.cpp @@ -196,6 +196,7 @@ void EntityTreeRenderer::update() { void EntityTreeRenderer::checkEnterLeaveEntities() { if (_tree) { + _tree->lockForRead(); glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition() / (float) TREE_SCALE; if (avatarPosition != _lastAvatarPosition) { @@ -240,6 +241,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { _currentEntitiesInside = entitiesContainingAvatar; _lastAvatarPosition = avatarPosition; } + _tree->unlock(); } } From 55576e7f9da9d0e50bee54106968cb7452e0c079 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 6 Nov 2014 17:53:22 -0800 Subject: [PATCH 3/3] 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