Fix #113603: User modified key-map preferences for add-ons don't load
Regression from [0] where the key-map was attempting to load preferences for key-map items for add-on operators which were not yet defined. Resolve by postponing keymap updating until after loading add-ons. [0]: 6de294a1915217c4711def25532d3d4b728b84d1
This commit is contained in:
parent
e4ad58114b
commit
cdbde7d941
@ -40,6 +40,9 @@ void WM_keyconfig_update_operatortype();
|
|||||||
void WM_keyconfig_update_suppress_begin();
|
void WM_keyconfig_update_suppress_begin();
|
||||||
void WM_keyconfig_update_suppress_end();
|
void WM_keyconfig_update_suppress_end();
|
||||||
|
|
||||||
|
void WM_keyconfig_update_postpone_begin();
|
||||||
|
void WM_keyconfig_update_postpone_end();
|
||||||
|
|
||||||
/* Keymap */
|
/* Keymap */
|
||||||
|
|
||||||
/** Parameters for matching events, passed into functions that create key-map items. */
|
/** Parameters for matching events, passed into functions that create key-map items. */
|
||||||
|
@ -446,7 +446,7 @@ void WM_keyconfig_init(bContext *C)
|
|||||||
if (!G.background) {
|
if (!G.background) {
|
||||||
WM_keyconfig_update_tag(nullptr, nullptr);
|
WM_keyconfig_update_tag(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
WM_keyconfig_update(wm);
|
/* Don't call #WM_keyconfig_update here because add-ons have not yet been registered yet. */
|
||||||
|
|
||||||
wm->init_flag |= WM_INIT_FLAG_KEYCONFIG;
|
wm->init_flag |= WM_INIT_FLAG_KEYCONFIG;
|
||||||
}
|
}
|
||||||
|
@ -366,12 +366,20 @@ void WM_init(bContext *C, int argc, const char **argv)
|
|||||||
STRNCPY(G.lib, BKE_main_blendfile_path_from_global());
|
STRNCPY(G.lib, BKE_main_blendfile_path_from_global());
|
||||||
|
|
||||||
CTX_py_init_set(C, true);
|
CTX_py_init_set(C, true);
|
||||||
|
|
||||||
|
/* Postpone updating the key-configuration until after add-ons have been registered,
|
||||||
|
* needed to properly load user-configured add-on key-maps, see: #113603. */
|
||||||
|
WM_keyconfig_update_postpone_begin();
|
||||||
|
|
||||||
WM_keyconfig_init(C);
|
WM_keyconfig_init(C);
|
||||||
|
|
||||||
/* Load add-ons after key-maps have been initialized (but before the blend file has been read),
|
/* Load add-ons after key-maps have been initialized (but before the blend file has been read),
|
||||||
* important to guarantee default key-maps have been declared & before post-read handlers run. */
|
* important to guarantee default key-maps have been declared & before post-read handlers run. */
|
||||||
wm_init_scripts_extensions_once(C);
|
wm_init_scripts_extensions_once(C);
|
||||||
|
|
||||||
|
WM_keyconfig_update_postpone_end();
|
||||||
|
WM_keyconfig_update(static_cast<wmWindowManager *>(G_MAIN->wm.first));
|
||||||
|
|
||||||
wm_homefile_read_post(C, params_file_read_post);
|
wm_homefile_read_post(C, params_file_read_post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1811,6 +1811,8 @@ enum {
|
|||||||
|
|
||||||
/* ensure all wmKeyMap have their operator types validated after removing an operator */
|
/* ensure all wmKeyMap have their operator types validated after removing an operator */
|
||||||
WM_KEYMAP_UPDATE_OPERATORTYPE = (1 << 1),
|
WM_KEYMAP_UPDATE_OPERATORTYPE = (1 << 1),
|
||||||
|
|
||||||
|
WM_KEYMAP_UPDATE_POSTPONE = (1 << 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
static char wm_keymap_update_flag = 0;
|
static char wm_keymap_update_flag = 0;
|
||||||
@ -1865,6 +1867,16 @@ void WM_keyconfig_update_suppress_end()
|
|||||||
wm_keymap_update_suppress_flag = 0;
|
wm_keymap_update_suppress_flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WM_keyconfig_update_postpone_begin()
|
||||||
|
{
|
||||||
|
wm_keymap_update_flag |= WM_KEYMAP_UPDATE_POSTPONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_keyconfig_update_postpone_end()
|
||||||
|
{
|
||||||
|
wm_keymap_update_flag &= ~WM_KEYMAP_UPDATE_POSTPONE;
|
||||||
|
}
|
||||||
|
|
||||||
static bool wm_keymap_test_and_clear_update(wmKeyMap *km)
|
static bool wm_keymap_test_and_clear_update(wmKeyMap *km)
|
||||||
{
|
{
|
||||||
int update = (km->flag & KEYMAP_UPDATE);
|
int update = (km->flag & KEYMAP_UPDATE);
|
||||||
@ -1902,6 +1914,12 @@ void WM_keyconfig_update_ex(wmWindowManager *wm, bool keep_properties)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Postpone update until after the key-map has been initialized
|
||||||
|
* to ensure add-ons have been loaded, see: #113603. */
|
||||||
|
if (wm_keymap_update_flag & WM_KEYMAP_UPDATE_POSTPONE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (wm_keymap_update_flag & WM_KEYMAP_UPDATE_OPERATORTYPE) {
|
if (wm_keymap_update_flag & WM_KEYMAP_UPDATE_OPERATORTYPE) {
|
||||||
/* One or more operator-types have been removed, this won't happen often
|
/* One or more operator-types have been removed, this won't happen often
|
||||||
* but when it does we have to check _every_ key-map item. */
|
* but when it does we have to check _every_ key-map item. */
|
||||||
|
Loading…
Reference in New Issue
Block a user