mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-23 08:09:08 +02:00
protect against crash on invalid scene on shutdown
This commit is contained in:
parent
014d7b8d8d
commit
da55c96c4c
2 changed files with 19 additions and 14 deletions
|
@ -1785,14 +1785,23 @@ void Application::cleanupBeforeQuit() {
|
||||||
DependencyManager::destroy<AudioClient>();
|
DependencyManager::destroy<AudioClient>();
|
||||||
DependencyManager::destroy<AudioInjectorManager>();
|
DependencyManager::destroy<AudioInjectorManager>();
|
||||||
|
|
||||||
// shutdown render engine
|
|
||||||
_main3DScene = nullptr;
|
|
||||||
_renderEngine = nullptr;
|
|
||||||
|
|
||||||
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application() {
|
Application::~Application() {
|
||||||
|
// remove avatars from physics engine
|
||||||
|
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
||||||
|
VectorOfMotionStates motionStates;
|
||||||
|
DependencyManager::get<AvatarManager>()->getObjectsToRemoveFromPhysics(motionStates);
|
||||||
|
_physicsEngine->removeObjects(motionStates);
|
||||||
|
DependencyManager::get<AvatarManager>()->deleteAllAvatars();
|
||||||
|
|
||||||
|
_physicsEngine->setCharacterController(nullptr);
|
||||||
|
|
||||||
|
// shutdown render engine
|
||||||
|
_main3DScene = nullptr;
|
||||||
|
_renderEngine = nullptr;
|
||||||
|
|
||||||
DependencyManager::destroy<Preferences>();
|
DependencyManager::destroy<Preferences>();
|
||||||
|
|
||||||
_entityClipboard->eraseAllOctreeElements();
|
_entityClipboard->eraseAllOctreeElements();
|
||||||
|
@ -1804,14 +1813,6 @@ Application::~Application() {
|
||||||
_octreeProcessor.terminate();
|
_octreeProcessor.terminate();
|
||||||
_entityEditSender.terminate();
|
_entityEditSender.terminate();
|
||||||
|
|
||||||
_physicsEngine->setCharacterController(nullptr);
|
|
||||||
|
|
||||||
// remove avatars from physics engine
|
|
||||||
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
|
||||||
VectorOfMotionStates motionStates;
|
|
||||||
DependencyManager::get<AvatarManager>()->getObjectsToRemoveFromPhysics(motionStates);
|
|
||||||
_physicsEngine->removeObjects(motionStates);
|
|
||||||
DependencyManager::get<AvatarManager>()->deleteAllAvatars();
|
|
||||||
|
|
||||||
DependencyManager::destroy<AvatarManager>();
|
DependencyManager::destroy<AvatarManager>();
|
||||||
DependencyManager::destroy<AnimationCache>();
|
DependencyManager::destroy<AnimationCache>();
|
||||||
|
|
|
@ -344,14 +344,18 @@ void AvatarManager::processAvatarDataPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
avatar->removeFromScene(avatar, scene, transaction);
|
avatar->removeFromScene(avatar, scene, transaction);
|
||||||
scene->enqueueTransaction(transaction);
|
if (scene) {
|
||||||
|
scene->enqueueTransaction(transaction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (_shouldRender) {
|
} else if (_shouldRender) {
|
||||||
// very rare transition so we process the transaction immediately
|
// very rare transition so we process the transaction immediately
|
||||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
avatar->addToScene(avatar, scene, transaction);
|
avatar->addToScene(avatar, scene, transaction);
|
||||||
scene->enqueueTransaction(transaction);
|
if (scene) {
|
||||||
|
scene->enqueueTransaction(transaction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue