You should issue the deleteUI call through evalDeferred.

(pardon the MEL :-))

{
   window theWindow;
   showWindow;
}

global proc deleteTheWindow()
{
   evalDeferred("deleteUI theWindow");
}

scriptJob -idleEvent "deleteTheWindow" -parent "theWindow" -runOnce true


On Fri, Oct 17, 2008 at 10:22 AM, barnabas79 <[EMAIL PROTECTED]> wrote:

>
> Just a FYI for anyone else out there - creating a scriptJob with the
> runOnce flag and the parent flag set to a piece of ui, whose script
> deletes that same piece of ui, will cause a crash.
>
> If you're unconditionally deleting the ui whenever the scriptJob is
> triggered, the easy workaround is simply to remove the runOnce flag,
> since this will not crash, and once the ui is deleted, the parent flag
> will cause the scriptJob to be deleted anyway.
>
> If, however, you're conditionally deleting it, then you'll have to
> pick which flag you want to use - the runOnce, or the parent flag...
>
> This crashed for me on 2008 Ext2 x64 and 2009 x64 (both on WinXP x64)
>
> - Paul
>
> # Execute the following python script in a new scene:
> import maya.cmds as cmds
>
> winName = "theWindow"
>
> # Make a window
> cmds.window(winName)
>
> def deleteWindow():
>    cmds.deleteUI(winName)
>
> # Add a callback which deletes the window, and has the window as it's
> parent
> # Note: runOnce option must be present for crash!!
> cmds.scriptJob(idleEvent=deleteWindow, parent=winName, runOnce=True)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to