Skip to content

Commit 604b117

Browse files
Fix segfault when panning map
1 parent 695a60f commit 604b117

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

callbacks.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,6 @@ void callback::MinimapMenu(int Param)
27032703
{
27042704
static CWindow* WNDMinimap = nullptr;
27052705
static CMap* MapObj = nullptr;
2706-
static SDL_Surface* WndSurface = nullptr;
27072706
static int scaleNum = 1;
27082707
// only in case INITIALIZING_CALL needed to create the window
27092708
int width;
@@ -2739,13 +2738,15 @@ void callback::MinimapMenu(int Param)
27392738
std::make_unique<CWindow>(MinimapMenu, WINDOWQUIT, WindowPos::Center, Extent(width + 12, height + 30),
27402739
"Overview", WINDOW_NOTHING, WINDOW_CLOSE | WINDOW_MOVE));
27412740
global::s2->RegisterCallback(MinimapMenu);
2742-
WndSurface = WNDMinimap->getSurface();
27432741
}
27442742
break;
27452743

27462744
case CALL_FROM_GAMELOOP:
2747-
if(MapObj && WndSurface)
2748-
MapObj->drawMinimap(WndSurface);
2745+
if(MapObj && WNDMinimap)
2746+
{
2747+
if(SDL_Surface* surf = WNDMinimap->getSurface())
2748+
MapObj->drawMinimap(surf);
2749+
}
27492750
break;
27502751

27512752
case WINDOW_CLICKED_CALL:
@@ -2777,7 +2778,6 @@ void callback::MinimapMenu(int Param)
27772778
WNDMinimap = nullptr;
27782779
}
27792780
MapObj = nullptr;
2780-
WndSurface = nullptr;
27812781
global::s2->UnregisterCallback(MinimapMenu);
27822782
break;
27832783

0 commit comments

Comments
 (0)