[Bf-blender-cvs] [308c4fc] master: Fix T42303 Icons lost after loading window

Antony Riakiotakis noreply at git.blender.org
Sun Oct 19 20:51:12 CEST 2014


Commit: 308c4fc234fce82b46ca03a27de7d9e0d69a7913
Author: Antony Riakiotakis
Date:   Sun Oct 19 20:50:43 2014 +0200
Branches: master
https://developer.blender.org/rB308c4fc234fce82b46ca03a27de7d9e0d69a7913

Fix T42303 Icons lost after loading window

The issue here is that if no matching winid is found, we destroy all
windows and their context with them. This will also delete the OpenGL
textures associated with the initial context, thus we lose the icons.
This patch makes sure a window is always kept for later so the initial
context does not get lost.

Thanks to Campbell and Ton for the discussion on the issue.

===================================================================

M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 832fef4..7865e09 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -171,6 +171,28 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
 #endif
 }
 
+static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWindow *win)
+{
+	win->ghostwin = oldwin->ghostwin;
+	win->active = oldwin->active;
+	if (win->active)
+		wm->winactive = win;
+
+	if (!G.background) /* file loading in background mode still calls this */
+		GHOST_SetWindowUserData(win->ghostwin, win);    /* pointer back */
+
+	oldwin->ghostwin = NULL;
+
+	win->eventstate = oldwin->eventstate;
+	oldwin->eventstate = NULL;
+
+	/* ensure proper screen rescaling */
+	win->sizex = oldwin->sizex;
+	win->sizey = oldwin->sizey;
+	win->posx = oldwin->posx;
+	win->posy = oldwin->posy;
+}
+
 /* match old WM with new, 4 cases:
  * 1- no current wm, no read wm: make new default
  * 2- no current wm, but read wm: that's OK, do nothing
@@ -224,6 +246,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
 			ED_screens_initialize(G.main->wm.first);
 		}
 		else {
+			bool has_match = false;
+
 			/* what if old was 3, and loaded 1? */
 			/* this code could move to setup_appdata */
 			oldwm = oldwmlist->first;
@@ -243,33 +267,27 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
 			/* ensure making new keymaps and set space types */
 			wm->initialized = 0;
 			wm->winactive = NULL;
-			
+
 			/* only first wm in list has ghostwins */
 			for (win = wm->windows.first; win; win = win->next) {
 				for (oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {
-					
-					if (oldwin->winid == win->winid) {
-						win->ghostwin = oldwin->ghostwin;
-						win->active = oldwin->active;
-						if (win->active)
-							wm->winactive = win;
 
-						if (!G.background) /* file loading in background mode still calls this */
-							GHOST_SetWindowUserData(win->ghostwin, win);    /* pointer back */
+					if (oldwin->winid == win->winid) {
+						has_match = true;
 
-						oldwin->ghostwin = NULL;
-						
-						win->eventstate = oldwin->eventstate;
-						oldwin->eventstate = NULL;
-						
-						/* ensure proper screen rescaling */
-						win->sizex = oldwin->sizex;
-						win->sizey = oldwin->sizey;
-						win->posx = oldwin->posx;
-						win->posy = oldwin->posy;
+						wm_window_substitute_old(wm, oldwin, win);
 					}
 				}
 			}
+
+			/* make sure at least one window is kept open so we don't lose the context, check T42303 */
+			if (!has_match) {
+				oldwin = oldwm->windows.first;
+				win = wm->windows.first;
+
+				wm_window_substitute_old(wm, oldwin, win);
+			}
+
 			wm_close_and_free_all(C, oldwmlist);
 		}
 	}




More information about the Bf-blender-cvs mailing list