Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

DeleteUI Fatal Error

DeleteUI Fatal Error

Anonymous
Not applicable
833 Views
1 Reply
Message 1 of 2

DeleteUI Fatal Error

Anonymous
Not applicable

I'm working on a tool that includes a language switch between English and Chinese, but when I want to reload my window or switch languages it results in a fatal crash in about 50-60% of the time. Sometimes crashing on the first reload/switch sometimes on a second or third.

I attempted to run it on an empty file on several computers, and attempted to remove the Chinese characters, but the error persisted in all cases. 

Am I doing something incorrect?

global proc BSTarget_StartUI(){

    global int $selectedLanguage;

	if (`window -ex BSTarget_Window` == 1){

	        deleteUI BSTarget_Window;

    	}

	if($selectedLanguage == 0){

	        string $BSTarget_Window = `window -t "Blendshape Target Tool" -menuBar true  -s  true -vis false   -mnb true  -mxb true -widthHeight 400 200  BSTarget_Window`;

        menu -label " File ";

            menuItem -label "Reload" -c BSTarget_StartUI;

            menuItem -divider true;

            menuItem -label "Exit" -c ("deleteUI -window " + $BSTarget_Window);

        menu -label "Language - 语言";

            menuItem -label  "English" -c switchToEnglish;

            menuItem -label  "中文" -c switchToChinese;

        window -e -s 1 -w 100 BSTarget_Window;

        showWindow BSTarget_Window;

    	}
    
	else if ($selectedLanguage == 1){

	        string $BSTarget_Window = `window -t "混合变形目标工具" -menuBar true  -s  true -vis false   -mnb true  -mxb true -widthHeight 400 200  BSTarget_Window`;

                menu -label "文件";

            menuItem -label "重装" -c BSTarget_StartUI;

            menuItem -divider true;

            menuItem -label "退出" -c ("deleteUI -window " + $BSTarget_Window);
 
        menu -label "Language - 语言";

            menuItem -label  "English" -c switchToEnglish;

            menuItem -label  "中文" -c switchToChinese;

        window -e -s 1 -w 100 BSTarget_Window;

        showWindow BSTarget_Window;

    	}

}



global proc switchToEnglish(){

    global int $selectedLanguage;

    $selectedLanguage = 0;

    BSTarget_StartUI;

}



global proc switchToChinese(){

    global int $selectedLanguage;

    $selectedLanguage = 1;

    BSTarget_StartUI;
    
}



BSTarget_StartUI; 
0 Likes
Accepted solutions (1)
834 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Solved, apparently crash was caused by the fact that I was deleting the UI from within itself.

 

Using evalDeferred fixed it.