try again: move stuff around in ~Application

This commit is contained in:
Andrew Meadows 2015-02-13 14:01:56 -08:00
parent 37be7251fe
commit 589077bce6

View file

@ -523,13 +523,21 @@ void Application::aboutToQuit() {
} }
void Application::cleanupBeforeQuit() { void Application::cleanupBeforeQuit() {
// make sure we don't call the idle timer any more
delete idleTimer;
// save state
QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection); QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
_settingsThread.quit(); _settingsThread.quit();
saveSettings(); saveSettings();
_window->saveGeometry();
// TODO: now that this is in cleanupBeforeQuit do we really need it to stop and force // TODO: now that this is in cleanupBeforeQuit do we really need it to stop and force
// an event loop to send the packet? // an event loop to send the packet?
UserActivityLogger::getInstance().close(); UserActivityLogger::getInstance().close();
// let the avatar mixer know we're out
MyAvatar::sendKillAvatar();
// stop the AudioClient // stop the AudioClient
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
@ -540,13 +548,12 @@ void Application::cleanupBeforeQuit() {
} }
Application::~Application() { Application::~Application() {
_window->saveGeometry(); EntityTree* tree = _entities.getTree();
tree->lockForWrite();
// make sure we don't call the idle timer any more _entities.getTree()->setSimulation(NULL);
delete idleTimer; tree->unlock();
// let the avatar mixer know we're out qInstallMessageHandler(NULL);
MyAvatar::sendKillAvatar();
// ask the datagram processing thread to quit and wait until it is done // ask the datagram processing thread to quit and wait until it is done
_nodeThread->quit(); _nodeThread->quit();
@ -565,13 +572,6 @@ Application::~Application() {
DependencyManager::destroy<GeometryCache>(); DependencyManager::destroy<GeometryCache>();
DependencyManager::destroy<ScriptCache>(); DependencyManager::destroy<ScriptCache>();
DependencyManager::destroy<SoundCache>(); DependencyManager::destroy<SoundCache>();
EntityTree* tree = _entities.getTree();
tree->lockForWrite();
_entities.getTree()->setSimulation(NULL);
tree->unlock();
qInstallMessageHandler(NULL);
} }
void Application::initializeGL() { void Application::initializeGL() {