MATLAB R2024a+ Crashing After Figure Closure

16 ビュー (過去 30 日間)
Gavriel Aminov
Gavriel Aminov 2024 年 12 月 3 日
コメント済み: Gavriel Aminov 2024 年 12 月 4 日
I've encountered a strange issue with MATLAB R2024a/b: the software crashes unexpectedly after closing a figure.
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 12 月 4 日
Which operating system is being used?
Gavriel Aminov
Gavriel Aminov 2024 年 12 月 4 日
Windows with proper update

サインインしてコメントする。

採用された回答

Gavriel Aminov
Gavriel Aminov 2024 年 12 月 3 日
The question was initiated by me myself for the answer on it, to help people in problem like I met.
Problem: MATLAB Crashing After Figure Closure
I've encountered a strange issue with MATLAB R2024a/b: the software crashes unexpectedly after closing a figure. This seems to be related to a custom DeleteFcn I've implemented for a line object within the figure.
When the figure is closed, MATLAB appears to call the DeleteFcn of the line object after the figure itself has been deleted. This leads to a crash as the DeleteFcn attempts to access the figure's axes handle, which no longer exists.
Solution:
To prevent this, we can add a check at the beginning of the DeleteFcn to determine the caller. If the caller is the figure closure process, the DeleteFcn can simply return without executing any further actions. Actually, any caller that is not empty must be treated the same way.
Code Example:
function DeleteLine(varargin) % DeleteFcn of line
% The gate
caller=dbstack(1);
if ~isempty(caller) % if strcmp(caller.name,'closereq')
return
end
% The body of DeleteFcn
ha=gca;
...
  2 件のコメント
Steven Lord
Steven Lord 2024 年 12 月 3 日
If MATLAB crashes (sometimes people say "MATLAB crashed" when they really observed MATLAB throwing an error) and you haven't already sent the crash report to Technical Support, please do so. That should help the development staff determine the root cause of the crash and fix the crash. Thanks.
Gavriel Aminov
Gavriel Aminov 2024 年 12 月 3 日
Done. Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by