Filter löschen
Filter löschen

Test for a handle to a deleted application

5 Ansichten (letzte 30 Tage)
Richard
Richard am 12 Jun. 2023
Bearbeitet: Richard am 12 Jun. 2023
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 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.")

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by