From 7efc2c2375bb591d57f6f3d63b274de48172e43b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Nov 2009 15:09:53 +0000 Subject: modify the python context access so invalid names will raise an exception rather then returning None. this way the UI scripts are less likely to fail silently and wont let typos work ok. also allow subclassing of the context, added a copy function, bpy.context.copy(), returns the context as a python dict to be modified and used in python. This also showed up an invalid brush member in the screen context. --- source/blender/editors/screen/screen_context.c | 7 +++++-- source/blender/editors/space_buttons/buttons_context.c | 5 ++++- source/blender/editors/space_view3d/space_view3d.c | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 31827e1b9c0..1a1def70717 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -67,7 +67,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult "visible_pchans", "selected_pchans", "active_bone", "active_pchan", "active_base", "active_object", "edit_object", "sculpt_object", "vertex_paint_object", "weight_paint_object", - "texture_paint_object", "brush", "particle_edit_object", NULL}; + "texture_paint_object", "particle_edit_object", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -304,7 +304,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } + else { + return 0; /* not found */ + } - return 0; + return -1; /* found but not available */ } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 71d5b59f253..0e2769a3557 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -707,8 +707,11 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r set_pointer_type(path, result, &RNA_Brush); return 1; } + else { + return 0; /* not found */ + } - return 0; + return -1; /* found but not available */ } /************************* Drawing the Path ************************/ diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 4a9042aa31c..5bde6e029e4 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -747,7 +747,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes return 1; } - return 0; + else { + return 0; /* not found */ + } + + return -1; /* found but not available */ } /* only called once, from space/spacetypes.c */ -- cgit v1.2.3