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().
This commit is contained in:
2014-04-07 17:13:06 +02:00
parent 163a3212b4
commit 6eb20ca048
2 changed files with 10 additions and 7 deletions

View File

@@ -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;

View File

@@ -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);