Fix #28769 & #28768: problem with duplicated keymap items after fix yesterday.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 29 Sep 2011 13:52:58 +0000 (13:52 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 29 Sep 2011 13:52:58 +0000 (13:52 +0000)
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/intern/wm.c

index 47ebf111ebab03ed02fecfe2943ae883ecbbcc1c..9e94ebfb6e883cf0f4f029da1d286ada33a08ca6 100644 (file)
@@ -295,6 +295,7 @@ typedef struct wmKeyConfig {
 
 /* wmKeyConfig.flag */
 #define KEYCONF_USER                   (1 << 1)
+#define KEYCONF_INIT_DEFAULT   (1 << 2)
 
 /* this one is the operator itself, stored in files for macros etc */
 /* operator + operatortype should be able to redo entirely, but for different contextes */
index 9299b50103c9011dca2782a2df3946eef24d4f73..5beb07a1ed0bbfda9d9ce680b011673f12b4b71b 100644 (file)
@@ -230,6 +230,7 @@ void WM_keymap_init(bContext *C)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
 
+       /* create standard key configs */
        if(!wm->defaultconf)
                wm->defaultconf= WM_keyconfig_new(wm, "Blender");
        if(!wm->addonconf)
@@ -237,10 +238,17 @@ void WM_keymap_init(bContext *C)
        if(!wm->userconf)
                wm->userconf= WM_keyconfig_new(wm, "Blender User");
        
+       /* initialize only after python init is done, for keymaps that
+          use python operators */
        if(CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) {
-               /* create default key config */
-               wm_window_keymap(wm->defaultconf);
-               ED_spacetypes_keymap(wm->defaultconf);
+               /* create default key config, only initialize once,
+                  it's persistent across sessions */
+               if(!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
+                       wm_window_keymap(wm->defaultconf);
+                       ED_spacetypes_keymap(wm->defaultconf);
+
+                       wm->defaultconf->flag |= KEYCONF_INIT_DEFAULT;
+               }
 
                WM_keyconfig_update_tag(NULL, NULL);
                WM_keyconfig_update(wm);