bugfix [#23423] Multi-window : closing game windows cause blender crash
detect closing window while the BGE runs and exit without crashing, as if Esc was pressed.
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
#include "BKE_anim.h"
|
||||
#include "BKE_action.h"
|
||||
@@ -1629,9 +1630,8 @@ void VIEW3D_OT_localview(wmOperatorType *ot)
|
||||
#ifdef WITH_GAMEENGINE
|
||||
|
||||
static ListBase queue_back;
|
||||
static void SaveState(bContext *C)
|
||||
static void SaveState(bContext *C, wmWindow *win)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
@@ -1646,9 +1646,8 @@ static void SaveState(bContext *C)
|
||||
//XXX waitcursor(1);
|
||||
}
|
||||
|
||||
static void RestoreState(bContext *C)
|
||||
static void RestoreState(bContext *C, wmWindow *win)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
|
||||
if(obact && obact->mode & OB_MODE_TEXTURE_PAINT)
|
||||
@@ -1662,7 +1661,8 @@ static void RestoreState(bContext *C)
|
||||
//XXX waitcursor(0);
|
||||
//XXX G.qual= 0;
|
||||
|
||||
win->queue= queue_back;
|
||||
if(win) /* check because closing win can set to NULL */
|
||||
win->queue= queue_back;
|
||||
|
||||
GPU_state_init();
|
||||
GPU_set_tpage(NULL, 0);
|
||||
@@ -1809,16 +1809,25 @@ static int game_engine_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
|
||||
SaveState(C);
|
||||
SaveState(C, prevwin);
|
||||
|
||||
StartKetsjiShell(C, ar, &cam_frame, 1);
|
||||
|
||||
/* window wasnt closed while the BGE was running */
|
||||
if(BLI_findindex(&CTX_wm_manager(C)->windows, prevwin) == -1) {
|
||||
prevwin= NULL;
|
||||
CTX_wm_window_set(C, NULL);
|
||||
}
|
||||
|
||||
/* 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_window_set(C, prevwin);
|
||||
CTX_wm_area_set(C, prevsa);
|
||||
RestoreState(C);
|
||||
if(prevwin) {
|
||||
/* 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_window_set(C, prevwin);
|
||||
CTX_wm_area_set(C, prevsa);
|
||||
}
|
||||
|
||||
RestoreState(C, prevwin);
|
||||
|
||||
//XXX restore_all_scene_cfra(scene_cfra_store);
|
||||
set_scene_bg(CTX_data_main(C), startscene);
|
||||
|
@@ -417,7 +417,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
||||
exitrequested = ketsjiengine->GetExitCode();
|
||||
|
||||
// kick the engine
|
||||
bool render = ketsjiengine->NextFrame(); // XXX 2.5 Bug, This is never true! FIXME- Campbell
|
||||
bool render = ketsjiengine->NextFrame();
|
||||
|
||||
if (render)
|
||||
{
|
||||
@@ -456,6 +456,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
||||
wm_event_free(event);
|
||||
}
|
||||
|
||||
if(win != CTX_wm_window(C)) {
|
||||
exitrequested= KX_EXIT_REQUEST_OUTSIDE; /* window closed while bge runs */
|
||||
}
|
||||
}
|
||||
printf("Blender Game Engine Finished\n");
|
||||
exitstring = ketsjiengine->GetExitString();
|
||||
@@ -506,8 +509,11 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
||||
startscene->camera= tmp_camera;
|
||||
}
|
||||
|
||||
// set the cursor back to normal
|
||||
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
|
||||
if(exitrequested != KX_EXIT_REQUEST_OUTSIDE)
|
||||
{
|
||||
// set the cursor back to normal
|
||||
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
|
||||
}
|
||||
|
||||
// clean up some stuff
|
||||
if (ketsjiengine)
|
||||
|
@@ -77,15 +77,6 @@ extern "C" {
|
||||
}
|
||||
|
||||
/* end of blender block */
|
||||
|
||||
/* was in drawmesh.c */
|
||||
void spack(unsigned int ucol)
|
||||
{
|
||||
char *cp= (char *)&ucol;
|
||||
|
||||
glColor3ub(cp[3], cp[2], cp[1]);
|
||||
}
|
||||
|
||||
void BL_warp_pointer(wmWindow *win, int x,int y)
|
||||
{
|
||||
WM_cursor_warp(win, x, y);
|
||||
|
@@ -946,6 +946,14 @@ int KX_KetsjiEngine::GetExitCode()
|
||||
if (m_scenes.begin()==m_scenes.end())
|
||||
m_exitcode = KX_EXIT_REQUEST_NO_SCENES_LEFT;
|
||||
}
|
||||
|
||||
// check if the window has been closed.
|
||||
if(!m_exitcode)
|
||||
{
|
||||
//if(!m_canvas->Check()) {
|
||||
// m_exitcode = KX_EXIT_REQUEST_OUTSIDE;
|
||||
//}
|
||||
}
|
||||
|
||||
return m_exitcode;
|
||||
}
|
||||
|
Reference in New Issue
Block a user