diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-03-29 12:29:40 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-03-29 12:39:36 +0300 |
commit | 870440dee910c908e213e5e2638ed2e0d0f010ae (patch) | |
tree | ab825c4aecf46f3b09ce383e7ffa062457f3c347 | |
parent | 2be098a1a02da30617516d32e6cd1409644c005e (diff) |
Prevent crash when seeing the window new on keymaps
CTX_data_main(C) is NULL in those cases :/
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 151c21d3cdd..69da8fd591b 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -817,23 +817,25 @@ struct EnumPropertyItem *wm_window_new_screen_itemf( * for dynamic strings in EnumPropertyItem.name to avoid this. */ static char active_screens[20][MAX_NAME + 12]; - for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { - if (screen->winid) { - BLI_snprintf(active_screens[count_act_screens], sizeof(*active_screens), "%s (Duplicate)", - screen->id.name + 2); - tmp.name = active_screens[count_act_screens++]; - } - else { - tmp.name = screen->id.name + 2; - } + if (bmain) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + if (screen->winid) { + BLI_snprintf(active_screens[count_act_screens], sizeof(*active_screens), "%s (Duplicate)", + screen->id.name + 2); + tmp.name = active_screens[count_act_screens++]; + } + else { + tmp.name = screen->id.name + 2; + } - tmp.value = value; - tmp.identifier = screen->id.name; - UI_id_icon_render(C, CTX_data_scene(C), &screen->id, true, false); - tmp.icon = BKE_icon_id_ensure(&screen->id); + tmp.value = value; + tmp.identifier = screen->id.name; + UI_id_icon_render(C, CTX_data_scene(C), &screen->id, true, false); + tmp.icon = BKE_icon_id_ensure(&screen->id); - RNA_enum_item_add(&item, &totitem, &tmp); - value++; + RNA_enum_item_add(&item, &totitem, &tmp); + value++; + } } RNA_enum_item_end(&item, &totitem); |