static void wm_window_match_do(bContext *C, ListBase *oldwmlist) { wmWindowManager *oldwm, *wm; wmWindow *oldwin, *win; /* cases 1 and 2 */ if (BLI_listbase_is_empty(oldwmlist)) { if (G.main->wm.first) { /* nothing todo */ } else { wm_add_default(C); } } else { /* cases 3 and 4 */ /* we've read file without wm..., keep current one entirely alive */ if (BLI_listbase_is_empty(&G.main->wm)) { bScreen *screen = NULL; /* when loading without UI, no matching needed */ if (!(G.fileflags & G_FILE_NO_UI) && (screen = CTX_wm_screen(C))) { /* match oldwm to new dbase, only old files */ for (wm = oldwmlist->first; wm; wm = wm->id.next) { for (win = wm->windows.first; win; win = win->next) { /* all windows get active screen from file */ if (screen->winid == 0) win->screen = screen; else win->screen = ED_screen_duplicate(win, screen); BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname)); win->screen->winid = win->winid; } } } G.main->wm = *oldwmlist; /* screens were read from file! */ 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; wm = G.main->wm.first; /* preserve key configurations in new wm, to preserve their keymaps */ wm->keyconfigs = oldwm->keyconfigs; wm->addonconf = oldwm->addonconf; wm->defaultconf = oldwm->defaultconf; wm->userconf = oldwm->userconf; BLI_listbase_clear(&oldwm->keyconfigs); oldwm->addonconf = NULL; oldwm->defaultconf = NULL; oldwm->userconf = NULL; /* 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) { has_match = true; 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); } } }
static void wm_window_match_do(bContext *C, ListBase *oldwmlist) { wmWindowManager *oldwm, *wm; wmWindow *oldwin, *win; /* cases 1 and 2 */ if(oldwmlist->first==NULL) { if(G.main->wm.first); /* nothing todo */ else wm_add_default(C); } else { /* cases 3 and 4 */ /* we've read file without wm..., keep current one entirely alive */ if(G.main->wm.first==NULL) { bScreen *screen= CTX_wm_screen(C); /* match oldwm to new dbase, only old files */ for(wm= oldwmlist->first; wm; wm= wm->id.next) { for(win= wm->windows.first; win; win= win->next) { /* all windows get active screen from file */ if(screen->winid==0) win->screen= screen; else win->screen= ED_screen_duplicate(win, screen); BLI_strncpy(win->screenname, win->screen->id.name+2, 21); win->screen->winid= win->winid; } } G.main->wm= *oldwmlist; /* screens were read from file! */ ED_screens_initialize(G.main->wm.first); } else { /* what if old was 3, and loaded 1? */ /* this code could move to setup_appdata */ oldwm= oldwmlist->first; wm= G.main->wm.first; /* 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; 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; } } } wm_close_and_free_all(C, oldwmlist); } } }
static int load_file(int UNUSED(argc), const char **argv, void *data) { bContext *C = data; /* Make the path absolute because its needed for relative linked blends to be found */ char filename[FILE_MAX]; /* note, we could skip these, but so far we always tried to load these files */ if (argv[0][0] == '-') { fprintf(stderr, "unknown argument, loading as file: %s\n", argv[0]); } BLI_strncpy(filename, argv[0], sizeof(filename)); BLI_path_cwd(filename); if (G.background) { int retval = BKE_read_file(C, filename, NULL); /* we successfully loaded a blend file, get sure that * pointcache works */ if (retval != BKE_READ_FILE_FAIL) { wmWindowManager *wm = CTX_wm_manager(C); /* special case, 2.4x files */ if (wm == NULL && CTX_data_main(C)->wm.first == NULL) { extern void wm_add_default(bContext *C); /* wm_add_default() needs the screen to be set. */ CTX_wm_screen_set(C, CTX_data_main(C)->screen.first); wm_add_default(C); } CTX_wm_manager_set(C, NULL); /* remove wm to force check */ WM_check(C); G.relbase_valid = 1; if (CTX_wm_manager(C) == NULL) CTX_wm_manager_set(C, wm); /* reset wm */ DAG_on_visible_update(CTX_data_main(C), TRUE); } else { /* failed to load file, stop processing arguments */ return -1; } /* WM_file_read() runs normally but since we're in background mode do here */ #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ BPY_python_reset(C); #endif /* happens for the UI on file reading too (huh? (ton))*/ // XXX BKE_reset_undo(); // BKE_write_undo("original"); /* save current state */ } else { /* we are not running in background mode here, but start blender in UI mode with * a file - this should do everything a 'load file' does */ ReportList reports; BKE_reports_init(&reports, RPT_PRINT); WM_file_autoexec_init(filename); WM_file_read(C, filename, &reports); BKE_reports_clear(&reports); } G.file_loaded = 1; return 0; }
static void wm_window_match_do(bContext *C, ListBase *oldwmlist) { wmWindowManager *oldwm, *wm; wmWindow *oldwin, *win; /* cases 1 and 2 */ if (oldwmlist->first == NULL) { if (G.main->wm.first) { /* nothing todo */ } else { wm_add_default(C); } } else { /* cases 3 and 4 */ /* we've read file without wm..., keep current one entirely alive */ if (G.main->wm.first == NULL) { bScreen *screen = NULL; /* when loading without UI, no matching needed */ if (!(G.fileflags & G_FILE_NO_UI) && (screen = CTX_wm_screen(C))) { /* match oldwm to new dbase, only old files */ for (wm = oldwmlist->first; wm; wm = wm->id.next) { for (win = wm->windows.first; win; win = win->next) { /* all windows get active screen from file */ if (screen->winid == 0) win->screen = screen; else win->screen = ED_screen_duplicate(win, screen); BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname)); win->screen->winid = win->winid; } } } G.main->wm = *oldwmlist; /* screens were read from file! */ ED_screens_initialize(G.main->wm.first); } else { /* what if old was 3, and loaded 1? */ /* this code could move to setup_appdata */ oldwm = oldwmlist->first; wm = G.main->wm.first; /* preserve key configurations in new wm, to preserve their keymaps */ wm->keyconfigs = oldwm->keyconfigs; wm->addonconf = oldwm->addonconf; wm->defaultconf = oldwm->defaultconf; wm->userconf = oldwm->userconf; oldwm->keyconfigs.first = oldwm->keyconfigs.last = NULL; oldwm->addonconf = NULL; oldwm->defaultconf = NULL; oldwm->userconf = NULL; /* 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 */ 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_close_and_free_all(C, oldwmlist); } } }