[Bf-blender-cvs] [6eb20ca] master: Fix own broken rB95b25e7333c4 (crash on any undo op :/).
Bastien Montagne
noreply at git.blender.org
Mon Apr 7 17:20:55 CEST 2014
Commit: 6eb20ca048e65871f12e8111512b69bacc599488
Author: Bastien Montagne
Date: Mon Apr 7 17:13:06 2014 +0200
https://developer.blender.org/rB6eb20ca048e65871f12e8111512b69bacc599488
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().
===================================================================
M source/blender/blenkernel/intern/context.c
M source/blender/editors/space_buttons/buttons_context.c
===================================================================
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 9dc6242..eeb1f4b 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 f71ffd8..8c12c6d 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);
More information about the Bf-blender-cvs
mailing list