Skip to content

Commit

Permalink
Improve check for selected lithophane image
Browse files Browse the repository at this point in the history
Checks for a Proxy attribute before accessing it and validates that the
proxy is an actual lithophane image by checking for the special attribute.

fixes #13
  • Loading branch information
furti committed Sep 6, 2018
1 parent ead5f14 commit 724e1a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lithophane_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def __init__(self, obj, imagePath):
obj.Proxy = self

self.lastPath = imagePath
self.pointCloudName = None
self.isLithophaneImage = True

def execute(self, fp):
'''Recompute the image when something changed'''
Expand Down
10 changes: 5 additions & 5 deletions lithophane_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def findSelectedImage():
selection = FreeCADGui.Selection.getSelection()

if len(selection) != 1:
return None
return (None, None)

selectedObject = selection[0]

if selectedObject.Proxy is None:
return None
if not hasattr(selectedObject, 'Proxy') or selectedObject.Proxy is None:
return (None, None)

#if not isinstance(selectedObject.Proxy, LithophaneImage):
# return None
if not hasattr(selectedObject.Proxy, 'isLithophaneImage') or not selectedObject.Proxy.isLithophaneImage:
return (None, None)

return (selection[0].Proxy, selection[0].Label)

Expand Down

0 comments on commit 724e1a1

Please sign in to comment.