From 2955d801d5900c7846b006dc9d44792e1515c664 Mon Sep 17 00:00:00 2001
From: Bastien Montagne <montagne29@wanadoo.fr>
Date: Mon, 5 Oct 2015 18:56:33 +0200
Subject: [PATCH] Fix T46383: "Import Images as Planes" should reload image
 datablock before importing.

There is now an option to force reloading existing images.

But main bug was elsewhere - that addon would always create new image datablocks, and yet
use same (already existing) texture afterwards, that was rather bad, fixed using new
'check_existing' option of load_image helper just added to master.
---
 io_import_images_as_planes.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py
index 8e54c91ba..27e8424b9 100644
--- a/io_import_images_as_planes.py
+++ b/io_import_images_as_planes.py
@@ -19,8 +19,8 @@
 bl_info = {
     "name": "Import Images as Planes",
     "author": "Florian Meyer (tstscr), mont29, matali",
-    "version": (2, 0, 2),
-    "blender": (2, 74, 0),
+    "version": (2, 0, 3),
+    "blender": (2, 76, 1),
     "location": "File > Import > Images as Planes or Add > Mesh > Images as Planes",
     "description": "Imports images and creates planes with the appropriate aspect ratio. "
                    "The images are mapped to the planes.",
@@ -179,6 +179,9 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
 
     align_offset = FloatProperty(name="Offset", min=0, soft_min=0, default=0.1, description="Space between Planes")
 
+    force_reload = BoolProperty(name="Force Reload", default=False,
+                                description="Force reloading of the image if already opened elsewhere in Blender")
+
     # Callback which will update File window's filter options accordingly to extension setting.
     def update_extensions(self, context):
         if self.extension == DEFAULT_EXT:
@@ -268,6 +271,8 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
         box.prop(self, "align")
         box.prop(self, "align_offset")
 
+        row = box.row()
+        row.prop(self, "force_reload")
         row = box.row()
         row.active = bpy.data.is_saved
         row.prop(self, "relative")
@@ -327,7 +332,8 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
         engine = context.scene.render.engine
         import_list, directory = self.generate_paths()
 
-        images = tuple(load_image(path, directory) for path in import_list)
+        images = tuple(load_image(path, directory, check_existing=True, force_reload=self.force_reload)
+                       for path in import_list)
 
         for img in images:
             self.set_image_options(img)
-- 
GitLab