Clear Filters
Clear Filters

Test for a handle to a deleted application

4 views (last 30 days)
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.

Accepted Answer

Image Analyst
Image Analyst on 12 Jun 2023
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.")

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!