1

I'm using App Designer to develop a GUI program. There is a loop which takes a lot of time in some callback functions. If I click exit button when one of the 'long' loop running, the app.UIFigure object will be deleted while the 'long' loop continue running. Then the statements in these callbacks which access the components of App will cause error "Invalid or Deleted Object".

Is there a method that can determine whether a callback function is running and end it before app.UIFigure object deleted. Below is the situation I want to solve. After I search in Google, I find use dbstack function can get all of the running functions(scripts) in MATLAB. It's best if I can get the running App(class) methods directly.

classdef myapp < matlab.app.AppBase
    properties
        something
    end
    methods
        %%%%%% a callback function takes a lot of time
        function longloop(app, event)
            while expression
                statements
            end
        end
        
        function UIFigureCloseRequest(app, event)
            %%%%% Here, I want to know how to determine whether other callback functions are running and end them.
            delete(app)
        end
        
        %%%% function automatically generated
        % Code that executes before app deletion
        function delete(app)
            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end

Thanks!

pure
  • 11
  • 1

0 Answers0