svn merge ^/trunk/blender -r49186:49190
[blender.git] / source / blender / editors / space_image / image_ops.c
index 42af515983ab34d7b2d44fe0f498b7279c0bcddc..8885b30842b69510b12cc5ef2f3c1715baf4040a 100644 (file)
@@ -902,6 +902,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;