fix annoying bug where image open from ID template didn't open in the existing images path.
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user