From adb5c3aa7f5431690c8c76ecc9a3b094bf675376 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 21 Aug 2019 21:32:34 +0100 Subject: [PATCH] Fix assert when exiting game in scenario editor The object selection window loads objects when it is closed which is triggered from window_close_all. We need to unload all the objects after this step on shutdown. --- src/openrct2/Context.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 3825470239..2d41b1d7f5 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -149,14 +149,17 @@ namespace OpenRCT2 // NOTE: We must shutdown all systems here before Instance is set back to null. // If objects use GetContext() in their destructor things won't go well. - if (_objectManager) + GameActions::ClearQueue(); + network_close(); + window_close_all(); + + // Unload objects after closing all windows, this is to overcome windows like + // the object selection window which loads objects when closed. + if (_objectManager != nullptr) { _objectManager->UnloadAll(); } - GameActions::ClearQueue(); - network_close(); - window_close_all(); gfx_object_check_all_images_freed(); gfx_unload_g2(); gfx_unload_g1();