Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-12-01 00:51:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-12-01 00:51:03 +0300
commitdf6169dada1bd6ad9617ef9e2adb17688f786314 (patch)
treebace5ff9cf42e703695bcd867a4afae9474a1ab6 /source
parent17cd5811e767df5bc7247648e3cbe52e39575f56 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c33
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp12
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp8
4 files changed, 38 insertions, 24 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 123c15bdb5b..c63bb7919a6 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -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);
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index c672d07a3cc..c9d85e6b48f 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -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)
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
index df3536424f6..2515c1738d7 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
@@ -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);
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index a1c7957dc72..35d02fbc9f4 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -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;
}