[Bf-blender-cvs] [bff3dcf3307] master: WM: always reset message-bus on file load
Campbell Barton
noreply at git.blender.org
Fri Oct 8 15:56:54 CEST 2021
Commit: bff3dcf3307a475916781994027dbd7d36f31b98
Author: Campbell Barton
Date: Fri Oct 8 23:41:47 2021 +1100
Branches: master
https://developer.blender.org/rBbff3dcf3307a475916781994027dbd7d36f31b98
WM: always reset message-bus on file load
Previously this was only happening when "Load UI" was enabled,
making it difficult for Python script authors to know when
re-registering subscribers was needed.
===================================================================
M source/blender/windowmanager/intern/wm_files.c
===================================================================
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a5ebf988edd..564f869581a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -204,6 +204,16 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
WM_event_remove_handlers(C, &win->modalhandlers);
ED_screen_exit(C, win, WM_window_get_active_screen(win));
}
+
+ /* NOTE(@campbellbarton): Clear the message bus so it's always cleared on file load.
+ * Otherwise it's cleared when "Load UI" is set (see #USER_FILENOUI & #wm_close_and_free).
+ * However it's _not_ cleared when the UI is kept. This complicates use from add-ons
+ * which can re-register subscribers on file-load. To support this use case,
+ * it's best to have predictable behavior - always clear. */
+ if (wm->message_bus != NULL) {
+ WM_msgbus_destroy(wm->message_bus);
+ wm->message_bus = NULL;
+ }
}
/* reset active window */
More information about the Bf-blender-cvs
mailing list