Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-06-12 18:36:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-12 18:36:24 +0300
commit031416c5590828e68090b9e6a10d96a70d537421 (patch)
tree8f8a3bee5e9b1c5d859024e889dec23db65cb42f /source
parente8dd4cd9cabb76f00838a975627c571a4fccdb18 (diff)
parentb00d84035989d3cef3417ee4f2ca8475c6c2b57a (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_screen.h1
-rw-r--r--source/blender/blenkernel/intern/screen.c14
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c30
4 files changed, 39 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 0b95152ad8e..4270e6eb1b4 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -305,6 +305,7 @@ typedef struct Menu {
/* spacetypes */
struct SpaceType *BKE_spacetype_from_id(int spaceid);
+struct ARegionType *BKE_regiontype_from_id_or_first(struct SpaceType *st, int regionid);
struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
const struct ListBase *BKE_spacetypes_list(void);
void BKE_spacetype_register(struct SpaceType *st);
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 8cff10902ef..b6b49a49de3 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -114,7 +114,7 @@ SpaceType *BKE_spacetype_from_id(int spaceid)
return NULL;
}
-ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
+ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
{
ARegionType *art;
@@ -126,6 +126,18 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
return st->regiontypes.first;
}
+ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
+{
+ ARegionType *art;
+
+ for (art = st->regiontypes.first; art; art = art->next) {
+ if (art->regionid == regionid) {
+ return art;
+ }
+ }
+ return NULL;
+}
+
const ListBase *BKE_spacetypes_list(void)
{
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index d2301fa74d4..6f2c443f16b 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1455,7 +1455,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
}
for (ar = sa->regionbase.first; ar; ar = ar->next)
- ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
+ ar->type = BKE_regiontype_from_id_or_first(sa->type, ar->regiontype);
/* area sizes */
area_calc_totrct(sa, &window_rect);
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 45d556d68e9..7adb1d40fcc 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -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;
}
}
@@ -210,10 +213,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 {
@@ -225,7 +234,10 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
else {
SpaceType *st = BKE_spacetype_from_id(spaceid);
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);
}
@@ -276,7 +288,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 {
@@ -288,7 +303,10 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
else {
SpaceType *st = BKE_spacetype_from_id(spaceid);
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);
}
}