diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-04-07 19:13:06 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-04-07 19:17:40 +0400 |
commit | 6eb20ca048e65871f12e8111512b69bacc599488 (patch) | |
tree | 759349e5e5960f8cbea47bc55cec6a81379c9cc4 | |
parent | 163a3212b471b4fe75a15600299e11a22d88a752 (diff) |
Fix own broken rB95b25e7333c4 (crash on any undo op :/).
Issue here was that buttons_texture_context_compute() was getting scene from (button-customized) context,
before the button paths (and hence, context) had been updated. So after an undo, it was getting an invalid
(freed by undo) scene pointer.
Now update BCONTEXT_SCENE path before calling buttons_texture_context_compute().
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 9dc62421349..eeb1f4b9e4f 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -873,7 +873,7 @@ Scene *CTX_data_scene(const bContext *C) { Scene *scene; - if (ctx_data_pointer_verify(C, "scene", (void *)&scene) && scene) + if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) return scene; else return C->data.scene; diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index f71ffd8c3f6..8c12c6dcf21 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -587,13 +587,16 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) PointerRNA *ptr; int a, pflag = 0, flag = 0; - buttons_texture_context_compute(C, sbuts); - if (!sbuts->path) sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); - + path = sbuts->path; - + + /* We need to set Scene path now! Else, buttons_texture_context_compute() might not get a valid scene. */ + buttons_context_path(C, path, BCONTEXT_SCENE, pflag); + + buttons_texture_context_compute(C, sbuts); + /* for each context, see if we can compute a valid path to it, if * this is the case, we know we have to display the button */ for (a = 0; a < BCONTEXT_TOT; a++) { @@ -682,8 +685,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "scene")) { - set_pointer_type(path, result, &RNA_Scene); - return 1; + /* Do not return one here if scene not found in path, in this case we want to get default context scene! */ + return set_pointer_type(path, result, &RNA_Scene); } else if (CTX_data_equals(member, "world")) { set_pointer_type(path, result, &RNA_World); |