diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-25 13:04:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-25 13:04:59 +0400 |
commit | 3af938918aae68488fc2fe8388f31ae4c3752b31 (patch) | |
tree | 75980ebc11c4b44f4561a2337255dfdd608c66fd | |
parent | 8f1666ee56c4ee30d2dfcc1c14d63fd398e164dc (diff) |
fix annoying bug where image open from ID template didn't open in the existing images path.
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 4702253140a..63b201e4cf7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -254,7 +254,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) break; case UI_ID_OPEN: case UI_ID_ADD_NEW: - /* these call uiIDContextPropertySet */ + /* these call uiIDContextProperty */ break; case UI_ID_DELETE: memset(&idptr, 0, sizeof(idptr)); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ca16558f3a6..7d1328ca266 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -901,6 +901,25 @@ static int image_open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) ima = tex->ima; } + if (ima == NULL) { + PointerRNA ptr; + PropertyRNA *prop; + + /* hook into UI */ + uiIDContextProperty(C, &ptr, &prop); + + if (prop) { + PointerRNA oldptr; + + oldptr = RNA_property_pointer_get(&ptr, prop); + ima = (Image *)oldptr.id.data; + /* unlikely but better avoid strange crash */ + if (ima && GS(ima->id.name) != ID_IM) { + ima = NULL; + } + } + } + if (ima) path = ima->name; |