Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'amaranth/scene/save_reload.py')
-rw-r--r--amaranth/scene/save_reload.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/amaranth/scene/save_reload.py b/amaranth/scene/save_reload.py
index f3bedb5e..ece61246 100644
--- a/amaranth/scene/save_reload.py
+++ b/amaranth/scene/save_reload.py
@@ -13,6 +13,23 @@ import bpy
KEYMAPS = list()
+def check_for_unsaved_images(self):
+ im_unsaved = []
+
+ for im in bpy.data.images:
+ if im.is_dirty:
+ im_unsaved.append(im.name)
+
+ if im_unsaved:
+ report_text = 'There are unsaved changes in {0} image(s), check console for details.'\
+ .format(len(im_unsaved))
+ self.report({"WARNING"}, report_text)
+
+ print("\nAmaranth found unsaved images when trying to save and reload.")
+ for im in im_unsaved:
+ print('* Image: "' + im + '" has unsaved changes.')
+ return True
+ return
class AMTH_WM_OT_save_reload(bpy.types.Operator):
"""Save and Reload the current blend file"""
@@ -23,6 +40,10 @@ class AMTH_WM_OT_save_reload(bpy.types.Operator):
if not path:
bpy.ops.wm.save_as_mainfile("INVOKE_AREA")
return
+
+ if check_for_unsaved_images(self):
+ return
+
bpy.ops.wm.save_mainfile()
self.report({"INFO"}, "Saved & Reloaded")
bpy.ops.wm.open_mainfile("EXEC_DEFAULT", filepath=path)