Fix #20323: closing other window while BGE is running crashes.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 14 Dec 2009 14:16:39 +0000 (14:16 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 14 Dec 2009 14:16:39 +0000 (14:16 +0000)
source/blender/editors/space_view3d/view3d_view.c

index a569eff1ebe155e7de7825a18087c056633e6df4..a4f24e900809e5882e15bf600829be75a9427a87 100644 (file)
@@ -1709,6 +1709,7 @@ static int game_engine_exec(bContext *C, wmOperator *unused)
        Scene *startscene = CTX_data_scene(C);
        ScrArea *sa, *prevsa= CTX_wm_area(C);
        ARegion *ar, *prevar= CTX_wm_region(C);
+       wmWindow *prevwin= CTX_wm_window(C);
        RegionView3D *rv3d;
        rcti cam_frame;
 
@@ -1742,11 +1743,15 @@ static int game_engine_exec(bContext *C, wmOperator *unused)
 
 
        SaveState(C);
+
        StartKetsjiShell(C, ar, &cam_frame, 1);
-       RestoreState(C);
        
+       /* restore context, in case it changed in the meantime, for
+          example by working in another window or closing it */
        CTX_wm_region_set(C, prevar);
        CTX_wm_area_set(C, prevsa);
+       CTX_wm_window_set(C, prevwin);
+       RestoreState(C);
 
        //XXX restore_all_scene_cfra(scene_cfra_store);
        set_scene_bg(startscene);