diff options
author | Peter Kim <pk15950@gmail.com> | 2022-09-08 07:00:43 +0300 |
---|---|---|
committer | Peter Kim <pk15950@gmail.com> | 2022-09-08 07:00:43 +0300 |
commit | e83f88c951e26b01893acee4f24b40a46062a41c (patch) | |
tree | 09f60bf7d4fc2ae1ef50668823e416fc675b252e /amaranth/scene/save_reload.py | |
parent | ec84e3294593e2e26475f18c81e847bf00dc201e (diff) | |
parent | 0cd92169d40ae1c7e103ff269e850eaf1b901646 (diff) |
Merge branch 'master' into xr-devxr-dev
Diffstat (limited to 'amaranth/scene/save_reload.py')
-rw-r--r-- | amaranth/scene/save_reload.py | 21 |
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) |