Skip to content

Commit 3db9168

Browse files
Ability to close all open 'MayaBaseWindow' class windows.
This can be used to clean up while closing Maya, or opening a new Maya scene file. Issue #222
1 parent 3c9a43b commit 3db9168

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

python/mmSolver/ui/base_maya_window.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ def get_instance(cls):
149149
instance = cls.instance
150150
return instance
151151

152+
@classmethod
153+
def close_all_instances(cls):
154+
global ALL_CLASS_INSTANCES
155+
for instance in ALL_CLASS_INSTANCES:
156+
if not instance:
157+
continue
158+
if uiutils.isValidQtObject(instance) is False:
159+
continue
160+
LOG.debug("Closing: %r", instance.objectName())
161+
instance.deleteLater()
162+
instance.close()
163+
del ALL_CLASS_INSTANCES
164+
ALL_CLASS_INSTANCES = set()
165+
return
166+
152167
@classmethod
153168
def open_window(cls, show=True, auto_raise=True, delete=False, dock=False):
154169
s = time.time()
@@ -163,7 +178,11 @@ def open_window(cls, show=True, auto_raise=True, delete=False, dock=False):
163178
name = cls.name
164179
app, parent = uiutils.getParent()
165180
cls.instance = cls(parent=parent, name=name)
166-
cls.instance.setDockableParameters(dockable=dock)
181+
# Do not retain the workspaceController after the window
182+
# has closed, if retain=True this causes errors when
183+
# windows are closed.
184+
retain = False
185+
cls.instance.setDockableParameters(dockable=dock, retain=retain)
167186

168187
# Make sure the user can see this window.
169188
if cls.instance.isHidden():

0 commit comments

Comments
 (0)