From e375459256efa9bc1bbb062e97498b6b5d7f0734 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sun, 24 Mar 2024 11:27:54 +0100 Subject: [PATCH] Fix previous commit: Remove `SDL_FreeSurface(HiddenSurface.get());`. --- src/video/cursor.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/video/cursor.cpp b/src/video/cursor.cpp index 55cff98c18..abd94b1867 100644 --- a/src/video/cursor.cpp +++ b/src/video/cursor.cpp @@ -340,24 +340,22 @@ void DrawCursor() // Last, Normal cursor. if (!Preference.HardwareCursor) { - const PixelPos pos = CursorScreenPos - GameCursor->HotPos; - - if (!GameRunning && !Editor.Running) { - if (!HiddenSurface - || HiddenSurface->w != GameCursor->G->getWidth() - || HiddenSurface->h != GameCursor->G->getHeight()) { - if (HiddenSurface) { - VideoPaletteListRemove(HiddenSurface.get()); - SDL_FreeSurface(HiddenSurface.get()); - } - HiddenSurface.reset(SDL_CreateRGBSurface(SDL_SWSURFACE, - GameCursor->G->getWidth(), - GameCursor->G->getHeight(), - TheScreen->format->BitsPerPixel, - TheScreen->format->Rmask, - TheScreen->format->Gmask, - TheScreen->format->Bmask, - TheScreen->format->Amask)); + const PixelPos pos = CursorScreenPos - GameCursor->HotPos; + + if (!GameRunning && !Editor.Running) { + if (!HiddenSurface || HiddenSurface->w != GameCursor->G->getWidth() + || HiddenSurface->h != GameCursor->G->getHeight()) { + if (HiddenSurface) { + VideoPaletteListRemove(HiddenSurface.get()); + } + HiddenSurface.reset(SDL_CreateRGBSurface(SDL_SWSURFACE, + GameCursor->G->getWidth(), + GameCursor->G->getHeight(), + TheScreen->format->BitsPerPixel, + TheScreen->format->Rmask, + TheScreen->format->Gmask, + TheScreen->format->Bmask, + TheScreen->format->Amask)); } SDL_Rect srcRect = { Sint16(pos.x), Sint16(pos.y), Uint16(GameCursor->G->getWidth()), Uint16(GameCursor->G->getHeight())}; SDL_BlitSurface(TheScreen, &srcRect, HiddenSurface.get(), nullptr);