WM: remove sloppy region type access
Avoid accidentally operating on the wrong region type.
This commit is contained in:
parent
760e79d809
commit
b00d840359
|
@ -197,7 +197,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
|
|||
|
||||
/* use optional regiondata callback */
|
||||
if (ar->regiondata) {
|
||||
ARegionType *art = BKE_regiontype_from_id_or_first(st, ar->regiontype);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
|
||||
|
||||
if (art && art->duplicate)
|
||||
newar->regiondata = art->duplicate(ar->regiondata);
|
||||
|
@ -307,7 +307,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
|
|||
uiList *uilst;
|
||||
|
||||
if (st) {
|
||||
ARegionType *art = BKE_regiontype_from_id_or_first(st, ar->regiontype);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
|
||||
|
||||
if (art && art->free)
|
||||
art->free(ar);
|
||||
|
|
|
@ -94,7 +94,7 @@ static int datadropper_init(bContext *C, wmOperator *op)
|
|||
ARegionType *art;
|
||||
|
||||
st = BKE_spacetype_from_id(SPACE_VIEW3D);
|
||||
art = BKE_regiontype_from_id_or_first(st, RGN_TYPE_WINDOW);
|
||||
art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
|
||||
|
||||
op->customdata = ddr = MEM_callocN(sizeof(DataDropper), "DataDropper");
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ static int depthdropper_init(bContext *C, wmOperator *op)
|
|||
ARegionType *art;
|
||||
|
||||
st = BKE_spacetype_from_id(SPACE_VIEW3D);
|
||||
art = BKE_regiontype_from_id_or_first(st, RGN_TYPE_WINDOW);
|
||||
art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
|
||||
|
||||
op->customdata = ddr = MEM_callocN(sizeof(DepthDropper), "DepthDropper");
|
||||
|
||||
|
|
|
@ -897,7 +897,7 @@ static void screen_refresh_headersizes(void)
|
|||
SpaceType *st;
|
||||
|
||||
for (st = lb->first; st; st = st->next) {
|
||||
ARegionType *art = BKE_regiontype_from_id_or_first(st, RGN_TYPE_HEADER);
|
||||
ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
|
||||
if (art) art->prefsizey = ED_area_headersize();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,10 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
|
|||
|
||||
if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
|
||||
if (cb_event_str) {
|
||||
if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == -1) {
|
||||
if (pyrna_enum_value_from_id(
|
||||
region_draw_mode_items, cb_event_str,
|
||||
&cb_event, "bpy_struct.callback_add()") == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -212,10 +215,16 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == -1) {
|
||||
if (pyrna_enum_value_from_id(
|
||||
region_draw_mode_items, cb_event_str,
|
||||
&cb_event, "bpy_struct.callback_add()") == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else if (pyrna_enum_value_from_id(rna_enum_region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_add()") == -1) {
|
||||
else if (pyrna_enum_value_from_id(
|
||||
rna_enum_region_type_items, cb_regiontype_str,
|
||||
&cb_regiontype, "bpy_struct.callback_add()") == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
@ -226,8 +235,11 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
|||
}
|
||||
else {
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id_or_first(st, cb_regiontype);
|
||||
|
||||
ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", cb_regiontype_str);
|
||||
return NULL;
|
||||
}
|
||||
handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, cb_event);
|
||||
Py_INCREF(args);
|
||||
}
|
||||
|
@ -278,7 +290,10 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
|
|||
customdata = ED_region_draw_cb_customdata(handle);
|
||||
Py_DECREF((PyObject *)customdata);
|
||||
|
||||
if (pyrna_enum_value_from_id(rna_enum_region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_remove()") == -1) {
|
||||
if (pyrna_enum_value_from_id(
|
||||
rna_enum_region_type_items, cb_regiontype_str,
|
||||
&cb_regiontype, "bpy_struct.callback_remove()") == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
@ -289,8 +304,11 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
|
|||
}
|
||||
else {
|
||||
SpaceType *st = BKE_spacetype_from_id(spaceid);
|
||||
ARegionType *art = BKE_regiontype_from_id_or_first(st, cb_regiontype);
|
||||
|
||||
ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype);
|
||||
if (art == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", cb_regiontype_str);
|
||||
return NULL;
|
||||
}
|
||||
ED_region_draw_cb_exit(art, handle);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue