From 52a16ea365e681a1fed15dfad921304f67e1b5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 29 Sep 2026 10:16:08 -0600 Subject: [PATCH] Make TempImage act a bit more robustly. --- Common/Render/ManagedTexture.cpp | 5 ----- Common/Render/ManagedTexture.h | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Common/Render/ManagedTexture.cpp b/Common/Render/ManagedTexture.cpp index ef4a46ddc1..59469c119f 100644 --- a/Common/Render/ManagedTexture.cpp +++ b/Common/Render/ManagedTexture.cpp @@ -54,11 +54,6 @@ private: ManagedTexture::LoadState *state_; }; -TempImage::~TempImage() { - // Make sure you haven't forgotten to call Free. - _dbg_assert_(levels[0] == nullptr); -} - static Draw::DataFormat ZimToT3DFormat(int zim) { switch (zim) { case ZIM_RGBA8888: return Draw::DataFormat::R8G8B8A8_UNORM; diff --git a/Common/Render/ManagedTexture.h b/Common/Render/ManagedTexture.h index af030b15c7..00f5dbf761 100644 --- a/Common/Render/ManagedTexture.h +++ b/Common/Render/ManagedTexture.h @@ -23,7 +23,13 @@ class LimitedWaitable; // The reason for the separation is so that the image can be loaded and decompressed on a thread, // and then only uploaded to the GPU on the main thread. struct TempImage { - ~TempImage(); + TempImage() = default; + // Owns levels[0], so no copies. + TempImage(const TempImage &) = delete; + TempImage &operator=(const TempImage &) = delete; + ~TempImage() { + Free(); + } Draw::DataFormat fmt = Draw::DataFormat::UNDEFINED; ImageFileType type = ImageFileType::UNKNOWN; uint8_t *levels[16]{}; // only free the first pointer, they all point to the same buffer.