Fix crash accessing enums without a context
This commit is contained in:
@@ -97,15 +97,14 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
|
|||||||
EvaluationContext eval_ctx;
|
EvaluationContext eval_ctx;
|
||||||
EnumPropertyItem *item = NULL, tmp_item = {0};
|
EnumPropertyItem *item = NULL, tmp_item = {0};
|
||||||
int totitem = 0;
|
int totitem = 0;
|
||||||
|
|
||||||
CTX_data_eval_ctx(C, &eval_ctx);
|
|
||||||
|
|
||||||
const int data_type = RNA_enum_get(ptr, "data_type");
|
const int data_type = RNA_enum_get(ptr, "data_type");
|
||||||
|
|
||||||
if (!C) { /* needed for docs and i18n tools */
|
if (!C) { /* needed for docs and i18n tools */
|
||||||
return rna_enum_dt_layers_select_src_items;
|
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_ACTIVE_SRC);
|
||||||
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
|
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,9 @@
|
|||||||
#include "BKE_screen.h"
|
#include "BKE_screen.h"
|
||||||
#include "BKE_workspace.h"
|
#include "BKE_workspace.h"
|
||||||
|
|
||||||
|
|
||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
#include "RNA_define.h"
|
#include "RNA_define.h"
|
||||||
|
#include "RNA_enum_types.h"
|
||||||
|
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
#include "WM_types.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(
|
const EnumPropertyItem *wm_window_new_screen_itemf(
|
||||||
bContext *C, struct PointerRNA *UNUSED(ptr), struct PropertyRNA *UNUSED(prop), bool *r_free)
|
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);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
WorkSpace *workspace = WM_window_get_active_workspace(win);
|
WorkSpace *workspace = WM_window_get_active_workspace(win);
|
||||||
ListBase *listbase = BKE_workspace_layouts_get(workspace);
|
ListBase *listbase = BKE_workspace_layouts_get(workspace);
|
||||||
|
|||||||
Reference in New Issue
Block a user