Skip to content

Commit

Permalink
Add isLoaded function to use instead of private variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter92 committed Feb 4, 2020
1 parent c81f321 commit e06dad2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 2 additions & 0 deletions vfxwindow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
Remove *_VERSION constants
Changed dialog to isDialog
Add dialog classmethod to replace cls.ForceDialog = True
Remove processEvents
Remove signalExists
"""

from __future__ import absolute_import
Expand Down
12 changes: 9 additions & 3 deletions vfxwindow/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(self, parent=None, **kwargs):
self.windowSettings = getWindowSettings(self.WindowID, path=self._windowDataPath)

self._signals = defaultdict(list)
self.__closed = False
self._windowClosed = self._windowLoaded = False
self.__dockable = getattr(self, 'WindowDockable', False)
self.__wasDocked = None
self.__initialPosOverride = None
Expand All @@ -125,6 +125,8 @@ def __init__(self, parent=None, **kwargs):
'callback': {}
}

self.windowReady.connect(lambda: setattr(self, '_windowLoaded', True))

def processEvents(self):
"""Wrapper over the inbult processEvents method.
This forces the GUI to update in the middle of calculations.
Expand Down Expand Up @@ -437,13 +439,17 @@ def clearWindowInstances(cls):

def closeEvent(self, event):
"""Close the window and mark it as closed."""
self.__closed = True
self._windowClosed = True
self.clearWindowInstance(self.WindowID)
return super(AbstractWindow, self).closeEvent(event)

def isClosed(self):
"""Return if the window has been closed."""
return self.__closed
return self._windowClosed

def isLoaded(self):
"""Return if the window is currently loaded."""
return self._windowLoaded and not self.isClosed()

def saveWindowPalette(self, program, version):
"""Save the palette as a file.
Expand Down
11 changes: 1 addition & 10 deletions vfxwindow/maya.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ def __init__(self, parent=None, dockable=False, **kwargs):
# The line below can save the window preferences, but this window automatically does it
#self.setProperty("saveWindowPref", True)

self.__windowReady = False
self.windowReady.connect(self.__setWindowReady)
self.__parentTemp = None

def visibleChangeEvent(self, *args, **kwargs):
Expand Down Expand Up @@ -856,19 +854,12 @@ def setFocus(self):
return pm.setFocus(self.WindowID)
return super(MayaWindow, self).setFocus()

def __setWindowReady(self):
"""Mark the window as ready.
This is needed for a recursion error caused by setVisiblity for
floating windows.
"""
self.__windowReady = True

def setVisible(self, visible):
"""Override setVisible to make sure it behaves like show/hide.
This can cause recursion errors, so make sure the window has
been loaded and not closed.
"""
if not self.__windowReady or self.isClosed() or self.isChildWindow():
if not self.isLoaded() or self.isChildWindow():
return super(MayaWindow, self).setVisible(visible)
if visible:
return self.show()
Expand Down

0 comments on commit e06dad2

Please sign in to comment.