fix annoying bug where image open from ID template didn't open in the existing images path.

This commit is contained in:
Campbell Barton
2012-07-25 09:04:59 +00:00
parent 8f1666ee56
commit 3af938918a
2 changed files with 20 additions and 1 deletions

View File

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

View File

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