필터 지우기
필터 지우기

Test for a handle to a deleted application

조회 수: 5 (최근 30일)
Richard
Richard 2023년 6월 12일
편집: Richard 2023년 6월 12일
Using App Designer I have a Main application that can create/open multiple instances of a graphics application. Each graphics instance is passed the handle (callingApp) of the Main App in order to access data and/or call various functions in the Main App. When a graphics instance is deleted I need to make a call to Main to update its data structures.
It's possible that the Main program will have been deleted accidentally or otherwise so I need to test the Main App handle to figure out whether it has been deleted. I have tried ishandle (just returns error is Main doesn't exist), exist (always seems to return " 1"), isobject (error if Main doesn't exist), isvalid (wants me to have another toolbox). What function is available that will solve this problem?
A fallback would be to have Main set flags in all the child graphics Apps as Main is being deleted, but that seems unnecessarily cumbersome. I could track the number of open children and prevent deleting Main if one or more graphics apps are open, but the simpler handle test logic is much preferred.

채택된 답변

Image Analyst
Image Analyst 2023년 6월 12일
Try wrapping it in a try catch. When the first thing you try to do forces it into the catch, you know it's been deleted. Then you can do whatever you want to do in that situation like update some structures in Main ("When a graphics instance is deleted I need to make a call to Main to update its data structures.")

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by