Fix assert when loading file with multiple windows opened
authorClément Foucault <foucault.clem@gmail.com>
Mon, 23 Jul 2018 15:44:16 +0000 (17:44 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Mon, 23 Jul 2018 15:44:34 +0000 (17:44 +0200)
... or when loading a file when having more windows opened than the file
itself.

source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_window.h

index c191255cd2161b9f47a0fd8545580b46ce22b62a..02c24aac60e35a3aa061fbe899e968cfa509573a 100644 (file)
@@ -279,6 +279,10 @@ static void wm_window_match_replace_by_file_wm(
        wm->initialized = 0;
        wm->winactive = NULL;
 
+       /* Clearing drawable of before deleting any context
+        * to avoid clearing the wrong wm. */
+       wm_window_clear_drawable(oldwm);
+
        /* only first wm in list has ghostwins */
        for (wmWindow *win = wm->windows.first; win; win = win->next) {
                for (wmWindow *oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {
index c1006db34efba8626c08bc4d1d04cb5e5a888623..4b26532742b6d29fefbfaaf973a2ca06877e8c58 100644 (file)
@@ -123,7 +123,6 @@ static struct WMInitStruct {
 /* ******** win open & close ************ */
 
 static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate);
-static void wm_window_clear_drawable(wmWindowManager *wm);
 
 /* XXX this one should correctly check for apple top header...
  * done for Cocoa : returns window contents (and not frame) max size*/
@@ -202,7 +201,6 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
                GHOST_DisposeWindow(g_system, win->ghostwin);
                win->ghostwin = NULL;
                win->gpuctx = NULL;
-
        }
 }
 
@@ -1103,7 +1101,7 @@ static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool acti
        immActivate();
 }
 
-static void wm_window_clear_drawable(wmWindowManager *wm)
+void wm_window_clear_drawable(wmWindowManager *wm)
 {
        if (wm->windrawable) {
                BLF_batch_reset();
index 385d61217adf5011741ff6d013570b2175def6e7..4fd5d66fb4374be7587684a020af44c5dc244502 100644 (file)
@@ -57,6 +57,7 @@ void          wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm);
 void           wm_window_process_events        (const bContext *C);
 void           wm_window_process_events_nosleep(void);
 
+void           wm_window_clear_drawable(wmWindowManager *wm);
 void           wm_window_make_drawable(wmWindowManager *wm, wmWindow *win);
 void           wm_window_reset_drawable(void);