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 Center および File ExchangeApp Building についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by