Images: move save modified images operator from Python to C
We will use this for saving images along with the .blend file. Ref D4861
This commit is contained in:
@@ -115,39 +115,6 @@ class EditExternally(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class SaveDirty(Operator):
|
||||
"""Save all modified textures"""
|
||||
bl_idname = "image.save_dirty"
|
||||
bl_label = "Save Dirty"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, _context):
|
||||
unique_paths = set()
|
||||
for image in bpy.data.images:
|
||||
if image.is_dirty:
|
||||
if image.packed_file:
|
||||
if image.library:
|
||||
self.report({'WARNING'},
|
||||
"Packed library image: %r from library %r"
|
||||
" can't be re-packed" %
|
||||
(image.name, image.library.filepath))
|
||||
else:
|
||||
image.pack()
|
||||
else:
|
||||
filepath = bpy.path.abspath(image.filepath,
|
||||
library=image.library)
|
||||
if "\\" not in filepath and "/" not in filepath:
|
||||
self.report({'WARNING'}, "Invalid path: " + filepath)
|
||||
elif filepath in unique_paths:
|
||||
self.report({'WARNING'},
|
||||
"Path used by more than one image: %r" %
|
||||
filepath)
|
||||
else:
|
||||
unique_paths.add(filepath)
|
||||
image.save()
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ProjectEdit(Operator):
|
||||
"""Edit a snapshot of the view-port in an external image editor"""
|
||||
bl_idname = "image.project_edit"
|
||||
@@ -248,5 +215,4 @@ classes = (
|
||||
EditExternally,
|
||||
ProjectApply,
|
||||
ProjectEdit,
|
||||
SaveDirty,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user