Effacer les filtres
Effacer les filtres

Test for a handle to a deleted application

5 vues (au cours des 30 derniers jours)
Richard
Richard le 12 Juin 2023
Modifié(e) : Richard le 12 Juin 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.

Réponse acceptée

Image Analyst
Image Analyst le 12 Juin 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.")

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by