Skip to content

Commit

Permalink
[FIX] Fix #383 - Don't error on trying to save default image to file
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Nov 10, 2017
1 parent d04cae2 commit 9271284
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/roam/api/featureform.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,9 @@ def save_images(values):
if hasattr(wrapper, 'savetofile') and wrapper.savetofile and wrapper.modified:
filename = values[field]
folder = self.form.project.image_folder
if not wrapper.saveable:
continue

saved = wrapper.save(folder, filename)
if not saved:
raise FeatureSaveException("Image Error",
Expand Down
14 changes: 14 additions & 0 deletions src/roam/editorwidgets/imagewidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,17 @@ def updatefromconfig(self):
def validate(self, *args):
return not self.widget.isDefault

@property
def saveable(self):
"""
Is the image saveable by the caller.
Mainly just a default or Null check so we don't save empty images.
:return:
"""
if self.widget.isDefault:
return False
return True

def showlargeimage(self, pixmap):
RoamEvents.openimage.emit(pixmap)

Expand All @@ -488,6 +499,9 @@ def get_filename(self):
return name

def save(self, folder, filename):
if not self.validate():
return False, None

saved, name = save_image(self.widget.getImage(), folder, filename)
return saved

Expand Down

0 comments on commit 9271284

Please sign in to comment.