Fix assert when loading file with multiple windows opened
[blender.git] / source / blender / windowmanager / intern / wm_files.c
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) {