diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-05-04 08:07:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-05-04 09:01:20 +0300 |
commit | 77e6a001a96b7eb3b2b1c2216a48c85c1b6906e0 (patch) | |
tree | ff2d44f3d8c661445e5d358f11e9043beadb23f0 /source/blender/editors/space_buttons/buttons_context.c | |
parent | 8d5e57748a777a76dbbe85d432d7d8364775713a (diff) |
Fix T44376: Buttons context, invalid data access
Removing a scene from the buttons window would crash from a Python operator.
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_context.c')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 73091e7f261..b00a2c54ff9 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -59,6 +59,7 @@ #include "RNA_access.h" +#include "ED_buttons.h" #include "ED_armature.h" #include "ED_screen.h" #include "ED_physics.h" @@ -1179,3 +1180,28 @@ ID *buttons_context_id_path(const bContext *C) return NULL; } + +void ED_buttons_id_unref(SpaceButs *sbuts, const ID *id) +{ + if (sbuts->path) { + ButsContextPath *path = sbuts->path; + int i; + + for (i = 0; i < path->len; i++) { + if (path->ptr[i].id.data == id) { + break; + } + } + + if (i == path->len) { + /* pass */ + } + else if (i == 0) { + MEM_SAFE_FREE(sbuts->path); + } + else { + memset(&path->ptr[i], 0, sizeof(path->ptr[i]) * (path->len - i)); + path->len = i; + } + } +} |