diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-01-30 19:45:25 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-01-30 19:45:25 +0300 |
commit | 128c8167afa003984b7446ad53915c79f872fdbf (patch) | |
tree | 383ddb7b187c35fb19669bb945c7430ac84d1dda | |
parent | b50ef7af146957c5c936f116ed5012db9e128c48 (diff) |
2.5: Fix for windows editmode tab crashes. This was due to
use of function pointers in the context callbacks. Apparently
MSVC decides that some of these functions are the same and
makes them into a single function with the same address. I
couldn't figure out if this was a compiler bug or according
to the C spec. Regardless, that means this method can't be
used, so now it uses separate CTX_DATA_DEFINES.
-rw-r--r-- | source/blender/blenkernel/BKE_context.h | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 42 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 14 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 3 |
9 files changed, 69 insertions, 54 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 160736d4a94..c489aba3326 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -59,13 +59,35 @@ struct wmWindowManager; struct bContext; typedef struct bContext bContext; -typedef void bContextDataMember; - struct bContextDataResult; typedef struct bContextDataResult bContextDataResult; +enum { + CTX_DATA_MAIN, + CTX_DATA_SCENE, + CTX_DATA_TOOL_SETTINGS, + + CTX_DATA_SELECTED_OBJECTS, + CTX_DATA_SELECTED_BASES, + CTX_DATA_SELECTED_EDITABLE_OBJECTS, + CTX_DATA_SELECTED_EDITABLE_BASES, + CTX_DATA_VISIBLE_OBJECTS, + CTX_DATA_VISIBLE_BASES, + + CTX_DATA_ACTIVE_OBJECT, + CTX_DATA_ACTIVE_BASE, + CTX_DATA_EDIT_OBJECT, + + CTX_DATA_EDIT_IMAGE, + CTX_DATA_EDIT_IMAGE_BUFFER, + + CTX_DATA_SELECTED_NODES +}; + +typedef int bContextDataMember; + typedef int (*bContextDataCallback)(const bContext *C, - const bContextDataMember *member, bContextDataResult *result); + bContextDataMember member, bContextDataResult *result); /* Context */ diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index a2e9329a18a..250aaf7245a 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -77,7 +77,7 @@ typedef struct SpaceType { void (*keymap)(struct wmWindowManager *); /* return context data */ - int (*context)(const struct bContext *, const void *, struct bContextDataResult *); + int (*context)(const struct bContext *, int, struct bContextDataResult *); /* region type definitions */ ListBase regiontypes; @@ -117,7 +117,7 @@ typedef struct ARegionType { void (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar); /* return context data */ - int (*context)(const struct bContext *, const void *, struct bContextDataResult *); + int (*context)(const struct bContext *, int, struct bContextDataResult *); /* custom drawing callbacks */ ListBase drawcalls; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 2a24e5a9d0f..ccdbea87d87 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -239,18 +239,12 @@ void CTX_wm_ui_block_set(bContext *C, struct uiBlock *block, bContextDataCallbac /* data context utility functions */ -struct bContextDataMember { - StructRNA *rna; - const char *name; - int collection; -}; - struct bContextDataResult { void *pointer; ListBase list; }; -static int ctx_data_get(bContext *C, const bContextDataMember *member, bContextDataResult *result) +static int ctx_data_get(bContext *C, bContextDataMember member, bContextDataResult *result) { int done= 0, recursion= C->data.recursion; @@ -284,7 +278,7 @@ static int ctx_data_get(bContext *C, const bContextDataMember *member, bContextD return done; } -static void *ctx_data_pointer_get(const bContext *C, const bContextDataMember *member) +static void *ctx_data_pointer_get(const bContext *C, bContextDataMember member) { bContextDataResult result; @@ -294,7 +288,7 @@ static void *ctx_data_pointer_get(const bContext *C, const bContextDataMember *m return NULL; } -static int ctx_data_pointer_verify(const bContext *C, const bContextDataMember *member, void **pointer) +static int ctx_data_pointer_verify(const bContext *C, bContextDataMember member, void **pointer) { bContextDataResult result; @@ -308,7 +302,7 @@ static int ctx_data_pointer_verify(const bContext *C, const bContextDataMember * } } -static int ctx_data_collection_get(const bContext *C, const bContextDataMember *member, ListBase *list) +static int ctx_data_collection_get(const bContext *C, bContextDataMember member, ListBase *list) { bContextDataResult result; @@ -351,7 +345,7 @@ Main *CTX_data_main(const bContext *C) { Main *bmain; - if(ctx_data_pointer_verify(C, CTX_data_main, (void*)&bmain)) + if(ctx_data_pointer_verify(C, CTX_DATA_MAIN, (void*)&bmain)) return bmain; else return C->data.main; @@ -366,7 +360,7 @@ Scene *CTX_data_scene(const bContext *C) { Scene *scene; - if(ctx_data_pointer_verify(C, CTX_data_scene, (void*)&scene)) + if(ctx_data_pointer_verify(C, CTX_DATA_SCENE, (void*)&scene)) return scene; else return C->data.scene; @@ -389,62 +383,62 @@ ToolSettings *CTX_data_tool_settings(const bContext *C) int CTX_data_selected_nodes(const bContext *C, ListBase *list) { - return ctx_data_collection_get(C, CTX_data_selected_nodes, list); + return ctx_data_collection_get(C, CTX_DATA_SELECTED_NODES, list); } int CTX_data_selected_editable_objects(const bContext *C, ListBase *list) { - return ctx_data_collection_get(C, CTX_data_selected_editable_objects, list); + return ctx_data_collection_get(C, CTX_DATA_SELECTED_EDITABLE_OBJECTS, list); } int CTX_data_selected_editable_bases(const bContext *C, ListBase *list) { - return ctx_data_collection_get(C, CTX_data_selected_editable_bases, list); + return ctx_data_collection_get(C, CTX_DATA_SELECTED_EDITABLE_BASES, list); } int CTX_data_selected_objects(const bContext *C, ListBase *list) { - return ctx_data_collection_get(C, CTX_data_selected_objects, list); + return ctx_data_collection_get(C, CTX_DATA_SELECTED_OBJECTS, list); } int CTX_data_selected_bases(const bContext *C, ListBase *list) { - return ctx_data_collection_get(C, CTX_data_selected_bases, list); + return ctx_data_collection_get(C, CTX_DATA_SELECTED_BASES, list); } int CTX_data_visible_objects(const bContext *C, ListBase *list) { - return ctx_data_collection_get(C, CTX_data_visible_objects, list); + return ctx_data_collection_get(C, CTX_DATA_VISIBLE_OBJECTS, list); } int CTX_data_visible_bases(const bContext *C, ListBase *list) { - return ctx_data_collection_get(C, CTX_data_visible_bases, list); + return ctx_data_collection_get(C, CTX_DATA_VISIBLE_BASES, list); } struct Object *CTX_data_active_object(const bContext *C) { - return ctx_data_pointer_get(C, CTX_data_active_object); + return ctx_data_pointer_get(C, CTX_DATA_ACTIVE_OBJECT); } struct Base *CTX_data_active_base(const bContext *C) { - return ctx_data_pointer_get(C, CTX_data_active_base); + return ctx_data_pointer_get(C, CTX_DATA_ACTIVE_BASE); } struct Object *CTX_data_edit_object(const bContext *C) { - return ctx_data_pointer_get(C, CTX_data_edit_object); + return ctx_data_pointer_get(C, CTX_DATA_EDIT_OBJECT); } struct Image *CTX_data_edit_image(const bContext *C) { - return ctx_data_pointer_get(C, CTX_data_edit_image); + return ctx_data_pointer_get(C, CTX_DATA_EDIT_IMAGE); } struct ImBuf *CTX_data_edit_image_buffer(const bContext *C) { - return ctx_data_pointer_get(C, CTX_data_edit_image_buffer); + return ctx_data_pointer_get(C, CTX_DATA_EDIT_IMAGE_BUFFER); } /* data evaluation */ diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index e5a1cb95f52..2406c1c5e32 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -33,20 +33,20 @@ #include "BKE_context.h" #include "BKE_utildefines.h" -int ed_screen_context(const bContext *C, const bContextDataMember *member, bContextDataResult *result) +int ed_screen_context(const bContext *C, bContextDataMember member, bContextDataResult *result) { bScreen *sc= CTX_wm_screen(C); Scene *scene= sc->scene; Base *base; - if(member == CTX_data_scene) { + if(member == CTX_DATA_SCENE) { CTX_data_pointer_set(result, scene); return 1; } - else if(ELEM(member, CTX_data_selected_objects, &CTX_data_selected_bases)) { + else if(ELEM(member, CTX_DATA_SELECTED_OBJECTS, CTX_DATA_SELECTED_BASES)) { for(base=scene->base.first; base; base=base->next) { if((base->flag & SELECT) && (base->lay & scene->lay)) { - if(member == CTX_data_selected_objects) + if(member == CTX_DATA_SELECTED_OBJECTS) CTX_data_list_add(result, base->object); else CTX_data_list_add(result, base); @@ -55,19 +55,19 @@ int ed_screen_context(const bContext *C, const bContextDataMember *member, bCont return 1; } - else if(member == CTX_data_active_base) { + else if(member == CTX_DATA_ACTIVE_BASE) { if(scene->basact) CTX_data_pointer_set(result, scene->basact); return 1; } - else if(member == CTX_data_active_object) { + else if(member == CTX_DATA_ACTIVE_OBJECT) { if(scene->basact) CTX_data_pointer_set(result, scene->basact->object); return 1; } - else if(member == CTX_data_edit_object) { + else if(member == CTX_DATA_EDIT_OBJECT) { /* convenience for now, 1 object per scene in editmode */ if(scene->obedit) CTX_data_pointer_set(result, scene->obedit); diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index fea46175f8d..862c434e3d4 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -56,7 +56,7 @@ void ed_screen_set(bContext *C, bScreen *sc); void ed_screen_fullarea(bContext *C); /* screen_context.c */ -void ed_screen_context(const bContext *C, const bContextDataMember *member, bContextDataResult *result); +void ed_screen_context(const bContext *C, bContextDataMember member, bContextDataResult *result); #endif /* ED_SCREEN_INTERN_H */ diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5ca1a54e40e..7929fcff716 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -230,15 +230,15 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } } -static int image_context(const bContext *C, const bContextDataMember *member, bContextDataResult *result) +static int image_context(const bContext *C, bContextDataMember member, bContextDataResult *result) { SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); - if(member == CTX_data_edit_image) { + if(member == CTX_DATA_EDIT_IMAGE) { CTX_data_pointer_set(result, get_space_image(sima)); return 1; } - else if(member == CTX_data_edit_image_buffer) { + else if(member == CTX_DATA_EDIT_IMAGE_BUFFER) { CTX_data_pointer_set(result, get_space_image_buffer(sima)); return 1; } diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 659069e321d..7febc1cc8e2 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -273,11 +273,11 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) } } -static int node_context(const bContext *C, const bContextDataMember *member, bContextDataResult *result) +static int node_context(const bContext *C, bContextDataMember member, bContextDataResult *result) { SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C); - if(member == CTX_data_selected_nodes) { + if(member == CTX_DATA_SELECTED_NODES) { bNode *node; for(next_node(snode->edittree); (node=next_node(NULL));) { diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index beaeb68e69a..e9602a3fe03 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -382,19 +382,19 @@ static int object_is_libdata(Object *ob) return 0; } -static int view3d_context(const bContext *C, const bContextDataMember *member, bContextDataResult *result) +static int view3d_context(const bContext *C, bContextDataMember member, bContextDataResult *result) { View3D *v3d= CTX_wm_view3d(C); Scene *scene= CTX_data_scene(C); Base *base; if(v3d==NULL) return 0; - - if(ELEM(member, CTX_data_selected_objects, CTX_data_selected_bases)) { + + if(ELEM(member, CTX_DATA_SELECTED_OBJECTS, CTX_DATA_SELECTED_BASES)) { for(base=scene->base.first; base; base=base->next) { if((base->flag & SELECT) && (base->lay & v3d->lay)) { if((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { - if(member == CTX_data_selected_objects) + if(member == CTX_DATA_SELECTED_OBJECTS) CTX_data_list_add(result, base->object); else CTX_data_list_add(result, base); @@ -404,12 +404,12 @@ static int view3d_context(const bContext *C, const bContextDataMember *member, b return 1; } - else if(ELEM(member, CTX_data_selected_editable_objects, CTX_data_selected_editable_bases)) { + else if(ELEM(member, CTX_DATA_SELECTED_EDITABLE_OBJECTS, CTX_DATA_SELECTED_EDITABLE_BASES)) { for(base=scene->base.first; base; base=base->next) { if((base->flag & SELECT) && (base->lay & v3d->lay)) { if((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { if(0==object_is_libdata(base->object)) { - if(member == CTX_data_selected_editable_objects) + if(member == CTX_DATA_SELECTED_EDITABLE_OBJECTS) CTX_data_list_add(result, base->object); else CTX_data_list_add(result, base); @@ -420,11 +420,11 @@ static int view3d_context(const bContext *C, const bContextDataMember *member, b return 1; } - else if(ELEM(member, CTX_data_visible_objects, CTX_data_visible_bases)) { + else if(ELEM(member, CTX_DATA_VISIBLE_OBJECTS, CTX_DATA_VISIBLE_BASES)) { for(base=scene->base.first; base; base=base->next) { if(base->lay & v3d->lay) { if((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { - if(member == CTX_data_visible_objects) + if(member == CTX_DATA_VISIBLE_OBJECTS) CTX_data_list_add(result, base->object); else CTX_data_list_add(result, base); @@ -434,14 +434,14 @@ static int view3d_context(const bContext *C, const bContextDataMember *member, b return 1; } - else if(member == CTX_data_active_base) { + else if(member == CTX_DATA_ACTIVE_BASE) { if(scene->basact && (scene->basact->lay & v3d->lay)) if((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0) CTX_data_pointer_set(result, scene->basact); return 1; } - else if(member == CTX_data_active_object) { + else if(member == CTX_DATA_ACTIVE_OBJECT) { if(scene->basact && (scene->basact->lay & v3d->lay)) if((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0) CTX_data_pointer_set(result, scene->basact->object); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 795d29ccde1..049c6564429 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -177,8 +177,7 @@ void view3d_keymap(wmWindowManager *wm) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_wpaint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); /* TODO - this is just while we have no way to load a text datablock */ - km = WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0); - RNA_string_set(km->ptr, "filename", "test.py"); + RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py"); transform_keymap_for_space(wm, keymap, SPACE_VIEW3D); |