From 090c444353dde5147c6b67189bc4d757fa0ffa6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 21 Apr 2018 23:03:03 +0200 Subject: [PATCH] Destroy context in TileElementWantsFootpathConnection::TearDownTestCase Not destroying the context might upset some compilers due to the order of destruction of variables the context might still require. --- test/tests/TileElements.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/tests/TileElements.cpp b/test/tests/TileElements.cpp index 6d11e4b1ec..ddbf982a23 100644 --- a/test/tests/TileElements.cpp +++ b/test/tests/TileElements.cpp @@ -28,6 +28,22 @@ protected: SUCCEED(); } + static void TearDownTestCase() + { + // FIXME: If this is not reset here, the context will outlive + // _availableObjectStringIds from Language.cpp, but upon its destruction + // OpenRCT2::Context::~Context() ../src/openrct2/Context.cpp:135 + // object_manager_unload_all_objects() ../src/openrct2/object/ObjectManager.cpp:620 + // ObjectManager::UnloadAll() ../src/openrct2/object/ObjectManager.cpp:207 + // ObjectManager::UnloadObject(Object*) ../src/openrct2/object/ObjectManager.cpp:329 + // RideObject::Unload() ../src/openrct2/object/RideObject.cpp:334 + // language_free_object_string(unsigned short) ../src/openrct2/localisation/Language.cpp:274 + // wants to access _availableObjectStringIds, which is already gone. + // + // This hack evicts context and ensures _availableObjectStringIds is + // available for the time we want to use it, until a better solution is implemented. + _context.reset(); + } private: static std::shared_ptr _context; };