Fix assert when loading file with multiple windows opened

... or when loading a file when having more windows opened than the file
itself.
This commit is contained in:
Clément Foucault 2018-07-23 17:44:16 +02:00
parent 87090abb95
commit 8876e3aae2
3 changed files with 6 additions and 3 deletions

View 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) {

View 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();

View 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);