Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -2897,43 +2897,59 @@ void Application::cleanupBeforeQuit() { · 2896 unmodified lines | |||
| 2897 | 2897 | ||
| 2898 | Application::~Application() { | 2898 | Application::~Application() { |
| 2899 | // remove avatars from physics engine | 2899 | // remove avatars from physics engine |
| 2900 | auto avatarManager = DependencyManager::get<AvatarManager>(); | 2900 | if (auto avatarManager = DependencyManager::get<AvatarManager>()) { |
| 2901 | avatarManager->clearOtherAvatars(); | 2901 | // AvatarManager may not yet exist in case of an early exit |
| 2902 | auto myCharacterController = getMyAvatar()->getCharacterController(); | 2902 | |
| 2903 | myCharacterController->clearDetailedMotionStates(); | 2903 | avatarManager->clearOtherAvatars(); |
| 2904 | auto myCharacterController = getMyAvatar()->getCharacterController(); | ||
| 2905 | myCharacterController->clearDetailedMotionStates(); | ||
| 2904 | 2906 | ||
| 2905 | PhysicsEngine::Transaction transaction; | 2907 | PhysicsEngine::Transaction transaction; |
| 2906 | avatarManager->buildPhysicsTransaction(transaction); | 2908 | avatarManager->buildPhysicsTransaction(transaction); |
| 2907 | _physicsEngine->processTransaction(transaction); | 2909 | _physicsEngine->processTransaction(transaction); |
| 2908 | avatarManager->handleProcessedPhysicsTransaction(transaction); | 2910 | avatarManager->handleProcessedPhysicsTransaction(transaction); |
| 2909 | avatarManager->deleteAllAvatars(); | 2911 | avatarManager->deleteAllAvatars(); |
| 2912 | } | ||
| 2910 | 2913 | ||
| 2911 | _physicsEngine->setCharacterController(nullptr); | 2914 | if (_physicsEngine) { |
| 2915 | _physicsEngine->setCharacterController(nullptr); | ||
| 2916 | } | ||
| 2912 | 2917 | ||
| 2913 | // the _shapeManager should have zero references | 2918 | // the _shapeManager should have zero references |
| 2914 | _shapeManager.collectGarbage(); | 2919 | _shapeManager.collectGarbage(); |
| 2915 | assert(_shapeManager.getNumShapes() == 0); | 2920 | assert(_shapeManager.getNumShapes() == 0); |
| 2916 | 2921 | ||
| 2917 | // shutdown graphics engine | 2922 | if (_graphicsEngine) { |
| 2918 | _graphicsEngine->shutdown(); | 2923 | // shutdown graphics engine |
| 2924 | _graphicsEngine->shutdown(); | ||
| 2925 | } | ||
| 2919 | 2926 | ||
| 2920 | _gameWorkload.shutdown(); | 2927 | _gameWorkload.shutdown(); |
| 2921 | 2928 | ||
| 2922 | DependencyManager::destroy<Preferences>(); | 2929 | DependencyManager::destroy<Preferences>(); |
| 2923 | PlatformHelper::shutdown(); | 2930 | PlatformHelper::shutdown(); |
| 2924 | 2931 | ||
| 2925 | _entityClipboard->eraseAllOctreeElements(); | 2932 | if (_entityClipboard) { |
| 2926 | _entityClipboard.reset(); | 2933 | _entityClipboard->eraseAllOctreeElements(); |
| 2934 | _entityClipboard.reset(); | ||
| 2935 | } | ||
| 2927 | 2936 | ||
| 2928 | _octreeProcessor->terminate(); | 2937 | if (_octreeProcessor) { |
| 2929 | _entityEditSender->terminate(); | 2938 | _octreeProcessor->terminate(); |
| 2939 | } | ||
| 2930 | 2940 | ||
| 2931 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { | 2941 | if (_entityEditSender) { |
| 2932 | steamClient->shutdown(); | 2942 | _entityEditSender->terminate(); |
| 2933 | } | 2943 | } |
| 2934 | 2944 | ||
| 2935 | if (auto oculusPlatform = PluginManager::getInstance()->getOculusPlatformPlugin()) { | 2945 | if (auto pluginManager = PluginManager::getInstance()) { |
| 2936 | oculusPlatform->shutdown(); | 2946 | if (auto steamClient = pluginManager->getSteamClientPlugin()) { |
| 2947 | steamClient->shutdown(); | ||
| 2948 | } | ||
| 2949 | |||
| 2950 | if (auto oculusPlatform = pluginManager->getOculusPlatformPlugin()) { | ||
| 2951 | oculusPlatform->shutdown(); | ||
| 2952 | } | ||
| 2937 | } | 2953 | } |
| 2938 | 2954 | ||
| 2939 | DependencyManager::destroy<PluginManager>(); | 2955 | DependencyManager::destroy<PluginManager>(); |
| @@ -2961,7 +2977,9 @@ Application::~Application() { · 21 unmodified lines | |||
| 2961 | DependencyManager::destroy<GeometryCache>(); | 2977 | DependencyManager::destroy<GeometryCache>(); |
| 2962 | DependencyManager::destroy<ScreenshareScriptingInterface>(); | 2978 | DependencyManager::destroy<ScreenshareScriptingInterface>(); |
| 2963 | 2979 | ||
| 2964 | DependencyManager::get<ResourceManager>()->cleanup(); | 2980 | if (auto resourceManager = DependencyManager::get<ResourceManager>()) { |
| 2981 | resourceManager->cleanup(); | ||
| 2982 | } | ||
| 2965 | 2983 | ||
| 2966 | // remove the NodeList from the DependencyManager | 2984 | // remove the NodeList from the DependencyManager |
| 2967 | DependencyManager::destroy<NodeList>(); | 2985 | DependencyManager::destroy<NodeList>(); |
| @@ -2975,13 +2993,14 @@ Application::~Application() { · 7 unmodified lines | |||
| 2975 | _window->deleteLater(); | 2993 | _window->deleteLater(); |
| 2976 | 2994 | ||
| 2977 | // make sure that the quit event has finished sending before we take the application down | 2995 | // make sure that the quit event has finished sending before we take the application down |
| 2978 | auto closeEventSender = DependencyManager::get<CloseEventSender>(); | 2996 | if (auto closeEventSender = DependencyManager::get<CloseEventSender>()) { |
| 2979 | while (!closeEventSender->hasFinishedQuitEvent() && !closeEventSender->hasTimedOutQuitEvent()) { | 2997 | while (!closeEventSender->hasFinishedQuitEvent() && !closeEventSender->hasTimedOutQuitEvent()) { |
| 2980 | // sleep a little so we're not spinning at 100% | 2998 | // sleep a little so we're not spinning at 100% |
| 2981 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); | 2999 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
| 3000 | } | ||
| 3001 | // quit the thread used by the closure event sender | ||
| 3002 | closeEventSender->thread()->quit(); | ||
| 2982 | } | 3003 | } |
| 2983 | // quit the thread used by the closure event sender | ||
| 2984 | closeEventSender->thread()->quit(); | ||
| 2985 | 3004 | ||
| 2986 | // Can't log to file past this point, FileLogger about to be deleted | 3005 | // Can't log to file past this point, FileLogger about to be deleted |
| 2987 | qInstallMessageHandler(LogHandler::verboseMessageHandler); | 3006 | qInstallMessageHandler(LogHandler::verboseMessageHandler); |