From 385c9ee5ffc38be6c822a51fb5958e38e0a21ca8 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 11 Aug 2021 17:51:20 +0200 Subject: [PATCH] Fix #15184: Crash when hovering over water types in Object Selection --- distribution/changelog.txt | 1 + src/openrct2/drawing/Image.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index f83f6731cc..c23034eb8b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -12,6 +12,7 @@ - Fix: [#15142] ToonTowner's mine roofs were moved into the pirate theme scenery group instead of the mine theme scenery group. - Fix: [#15148] Track Designs Manager delete confirmation window doesn't display properly. - Fix: [#15170] Plugin: incorrect label text alignment. +- Fix: [#15184] Crash when hovering over water types in Object Selection. - Improved: [#3417] Crash dumps are now placed in their own folder. - Change: [#8601] Revert ToonTower base block fix to re-enable support blocking. - Change: [#15174] [Plugin] Deprecate the type "peep" and add support to target a specific scripting api version. diff --git a/src/openrct2/drawing/Image.cpp b/src/openrct2/drawing/Image.cpp index ea6ab9f4c3..3e54059abd 100644 --- a/src/openrct2/drawing/Image.cpp +++ b/src/openrct2/drawing/Image.cpp @@ -30,7 +30,7 @@ static bool _initialised = false; static std::list _freeLists; static uint32_t _allocatedImageCount; -#ifdef DEBUG +#ifdef DEBUG_LEVEL_1 static std::list _allocatedLists; // MSVC's compiler doesn't support the [[maybe_unused]] attribute for unused static functions. Until this has been resolved, we @@ -76,7 +76,7 @@ static void InitialiseImageList() _freeLists.clear(); _freeLists.push_back({ BASE_IMAGE_ID, MAX_IMAGES }); -#ifdef DEBUG +#ifdef DEBUG_LEVEL_1 _allocatedLists.clear(); #endif _allocatedImageCount = 0; @@ -124,7 +124,7 @@ static uint32_t TryAllocateImageList(uint32_t count) _freeLists.push_back(remainder); } -#ifdef DEBUG +#ifdef DEBUG_LEVEL_1 _allocatedLists.push_back({ imageList.BaseId, count }); #endif _allocatedImageCount += count; @@ -163,9 +163,11 @@ static void FreeImageList(uint32_t baseImageId, uint32_t count) Guard::Assert(_initialised, GUARD_LINE); Guard::Assert(baseImageId >= BASE_IMAGE_ID, GUARD_LINE); -#ifdef DEBUG - bool contains = AllocatedListRemove(baseImageId, count); - Guard::Assert(contains, GUARD_LINE); +#ifdef DEBUG_LEVEL_1 + if (!AllocatedListRemove(baseImageId, count)) + { + log_error("Cannot unload %u items from offset %u", count, baseImageId); + } #endif _allocatedImageCount -= count; @@ -234,7 +236,7 @@ void gfx_object_check_all_images_freed() { if (_allocatedImageCount != 0) { -#ifdef DEBUG +#ifdef DEBUG_LEVEL_1 Guard::Assert(_allocatedImageCount == 0, "%u images were not freed", _allocatedImageCount); #else Console::Error::WriteLine("%u images were not freed", _allocatedImageCount);