Fix crash accessing enums without a context

This commit is contained in:
2017-10-18 19:46:39 +11:00
parent ec2bbc90e7
commit ecf20e7a56
2 changed files with 6 additions and 4 deletions

View File

@@ -97,15 +97,14 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
EvaluationContext eval_ctx;
EnumPropertyItem *item = NULL, tmp_item = {0};
int totitem = 0;
CTX_data_eval_ctx(C, &eval_ctx);
const int data_type = RNA_enum_get(ptr, "data_type");
if (!C) { /* needed for docs and i18n tools */
return rna_enum_dt_layers_select_src_items;
}
CTX_data_eval_ctx(C, &eval_ctx);
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC);
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);

View File

@@ -59,9 +59,9 @@
#include "BKE_screen.h"
#include "BKE_workspace.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -883,6 +883,9 @@ int wm_window_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(even
const EnumPropertyItem *wm_window_new_screen_itemf(
bContext *C, struct PointerRNA *UNUSED(ptr), struct PropertyRNA *UNUSED(prop), bool *r_free)
{
if (C == NULL) {
return DummyRNA_NULL_items;
}
wmWindow *win = CTX_wm_window(C);
WorkSpace *workspace = WM_window_get_active_workspace(win);
ListBase *listbase = BKE_workspace_layouts_get(workspace);