Finding/deleting existing workspaceControl

Finding/deleting existing workspaceControl

Anonymous
Not applicable
1,892 Views
4 Replies
Message 1 of 5

Finding/deleting existing workspaceControl

Anonymous
Not applicable

I have a docking window implemented as a workspaceControl, subclassed from MayaQWidgetDockableMixin like this:

    class ToolBrowserWindow(MayaQWidgetDockableMixin, base_class, form_class):

 

 

It may be called/recreated multiple times, so I want to delete any existing instances before creating the workspaceControl.
I'm currently doing this:

self.setObjectName(name)
workspaceControlName = self.objectName() + 'WorkspaceControl'
     
# Delete existing instance (error comes from here)
if maya.cmds.workspaceControl(workspaceControlName, exists=True):
maya.cmds.workspaceControl(workspaceControlName, edit=True, close=True)
maya.cmds.deleteUI(workspaceControlName, control=True) self.show(dockable=True, area='right', floating=True) mayaWorkspaceControl = maya.cmds.workspaceControl(...)

Which appears to work, except I get this error printed:

# Exception RuntimeError: 'Internal C++ object (ToolBrowserWindow) already deleted.' in <bound method ToolBrowserWindow.__del__ of <toolBrowserWindow.ToolBrowserWindow object at 0x000000000C800388>> ignored

What am I doing wrong?

0 Likes
1,893 Views
4 Replies
Replies (4)
Message 2 of 5

rajasekaransurjen
Collaborator
Collaborator
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks for the reply.  That's the same code I'm already using ( Example_connectAttr.deleteControl() )

It works for me in that example, but for my ui, when I call this:

cmds.deleteUI(control, control=True)

I get this:

# Exception RuntimeError: 'Internal C++ object (ToolBrowserWindow) already deleted.' in <bound method ToolBrowserWindow.__del__ of <toolBrowserWindow.ToolBrowserWindow object at 0x000000000C538848>> ignored


The message says it's ignored and all seems to work properly, but obviously something is different about my ui class, and I'd like to figure out what I'm doing wrong...

0 Likes
Message 4 of 5

Anonymous
Not applicable

I can get rid of the error by overloading the __del__() method as a NOP in my ToolBrowser class, so the one in the parent class MayaQWidgetDockableMixin doesn't get called.   That's obviously not the right way to do it, but maybe offers a clue as to what's going on...?

0 Likes
Message 5 of 5

rajasekaransurjen
Collaborator
Collaborator

If you can share the code for UI.

0 Likes