From 46abf5f31f5fd0b3e891ce33f07fd6dbf4e84e4b Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Thu, 10 Nov 2016 17:02:19 +0800 Subject: [PATCH] Set Game_wind to nullptr at the start of responding to EVENT_WINDOW_CLOSE in game_handler This prevents newdemo_stop_playback from attempting to close Game_wind, which results in it being freed twice - in particular when switching to the editor (via delete-E) when playing a demo. --- similar/main/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/similar/main/game.cpp b/similar/main/game.cpp index eaf6ea889..337926f97 100644 --- a/similar/main/game.cpp +++ b/similar/main/game.cpp @@ -1281,6 +1281,7 @@ window_event_result game_handler(window *,const d_event &event, const unused_win break; case EVENT_WINDOW_CLOSE: + Game_wind = nullptr; // Don't let any of the code below close Game_wind - it's already being done! digi_stop_digi_sounds(); if ( (Newdemo_state == ND_STATE_RECORDING) || (Newdemo_state == ND_STATE_PAUSED) ) @@ -1299,7 +1300,6 @@ window_event_result game_handler(window *,const d_event &event, const unused_win if (!EditorWindow) // have to do it this way because of the necessary longjmp. Yuck. #endif show_menus(); - Game_wind = NULL; event_toggle_focus(0); key_toggle_repeat(1); return window_event_result::ignored;