Skip to content

Commit 74d768d

Browse files
morganchristianssonMorgan Christiansson
authored andcommitted
Fix segfault when panning map
1 parent 05fcd18 commit 74d768d

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
@@ -2819,7 +2819,6 @@ void callback::MinimapMenu(int Param)
28192819
{
28202820
static CWindow* WNDMinimap = nullptr;
28212821
static CMap* MapObj = nullptr;
2822-
static SDL_Surface* WndSurface = nullptr;
28232822
static int scaleNum = 1;
28242823
// only in case INITIALIZING_CALL needed to create the window
28252824
int width;
@@ -2855,13 +2854,15 @@ void callback::MinimapMenu(int Param)
28552854
std::make_unique<CWindow>(MinimapMenu, WINDOWQUIT, WindowPos::Center, Extent(width + 12, height + 30),
28562855
"Overview", WINDOW_NOTHING, WINDOW_CLOSE | WINDOW_MOVE));
28572856
global::s2->RegisterCallback(MinimapMenu);
2858-
WndSurface = WNDMinimap->getSurface();
28592857
}
28602858
break;
28612859

28622860
case CALL_FROM_GAMELOOP:
2863-
if(MapObj && WndSurface)
2864-
MapObj->drawMinimap(WndSurface);
2861+
if(MapObj && WNDMinimap)
2862+
{
2863+
if(SDL_Surface* surf = WNDMinimap->getSurface())
2864+
MapObj->drawMinimap(surf);
2865+
}
28652866
break;
28662867

28672868
case WINDOW_CLICKED_CALL:
@@ -2893,7 +2894,6 @@ void callback::MinimapMenu(int Param)
28932894
WNDMinimap = nullptr;
28942895
}
28952896
MapObj = nullptr;
2896-
WndSurface = nullptr;
28972897
global::s2->UnregisterCallback(MinimapMenu);
28982898
break;
28992899

0 commit comments

Comments
 (0)