Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_blender.h" | #include "BKE_blender.h" | ||||
| #include "BKE_blendfile.h" | #include "BKE_blendfile.h" | ||||
| #include "BKE_callbacks.h" | #include "BKE_callbacks.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_lib_override.h" | #include "BKE_lib_override.h" | ||||
| #include "BKE_lib_remap.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_packedFile.h" | #include "BKE_packedFile.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_sound.h" | #include "BKE_sound.h" | ||||
| #include "BKE_undo_system.h" | #include "BKE_undo_system.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| ▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | |||||
| static void wm_window_match_replace_by_file_wm(bContext *C, | static void wm_window_match_replace_by_file_wm(bContext *C, | ||||
| ListBase *current_wm_list, | ListBase *current_wm_list, | ||||
| ListBase *readfile_wm_list, | ListBase *readfile_wm_list, | ||||
| ListBase *r_new_wm_list) | ListBase *r_new_wm_list) | ||||
| { | { | ||||
| wmWindowManager *oldwm = current_wm_list->first; | wmWindowManager *oldwm = current_wm_list->first; | ||||
| wmWindowManager *wm = readfile_wm_list->first; /* will become our new WM */ | wmWindowManager *wm = readfile_wm_list->first; /* will become our new WM */ | ||||
| /* Support window-manager ID references being held between file load operations by keeping | |||||
| * #Main.wm.first memory address in-place, while swapping all of it's contents. | |||||
| * | |||||
| * This is needed so items such as key-maps can be held by an add-on, | |||||
| * without it pointing to invalid memory, see: T86431 */ | |||||
| { | |||||
| /* Referencing the window-manager pointer from elsewhere in the file is highly unlikely | |||||
| * however it's possible with ID-properties & animation-drivers. | |||||
| * At some point we could check on disallowing this since it doesn't seem practical. */ | |||||
| Main *bmain = G_MAIN; | |||||
| BLI_assert(bmain->relations == NULL); | |||||
| BKE_libblock_relink_to_newid(&wm->id); | |||||
| BKE_libblock_remap(bmain, wm, oldwm, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_USER_CLEAR); | |||||
| /* Update ID's. */ | |||||
| BLI_remlink(current_wm_list, oldwm); | |||||
| BLI_remlink(readfile_wm_list, wm); | |||||
| SWAP(wmWindowManager, *oldwm, *wm); | |||||
| SWAP(wmWindowManager *, oldwm, wm); | |||||
| BLI_addhead(current_wm_list, oldwm); | |||||
| BLI_addhead(readfile_wm_list, wm); | |||||
| } | |||||
| bool has_match = false; | bool has_match = false; | ||||
| /* this code could move to setup_appdata */ | /* this code could move to setup_appdata */ | ||||
| /* preserve key configurations in new wm, to preserve their keymaps */ | /* preserve key configurations in new wm, to preserve their keymaps */ | ||||
| wm->keyconfigs = oldwm->keyconfigs; | wm->keyconfigs = oldwm->keyconfigs; | ||||
| wm->addonconf = oldwm->addonconf; | wm->addonconf = oldwm->addonconf; | ||||
| wm->defaultconf = oldwm->defaultconf; | wm->defaultconf = oldwm->defaultconf; | ||||
| ▲ Show 20 Lines • Show All 3,098 Lines • Show Last 20 Lines | |||||