summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dc62108)
raw | patch | inline | side by side (parent: dc62108)
author | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Tue, 19 Sep 2023 16:45:12 +0000 (02:45 +1000) | ||
committer | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Tue, 19 Sep 2023 16:45:12 +0000 (02:45 +1000) |
Verbatim warning text: "WARNING: TMenuItem.Destroy with LCLRefCount>0. Hint: Maybe the component is processing an event?".
This was caused by a complex call chain of miRecentFileExecute() -> OpenMap() -> RefreshRecentMenu() -> RefillRecentMenu(), which result in the sender menu item being removed.
In such cases, Application.ReleaseComponent() should be used.
https://forum.lazarus.freepascal.org/index.php?topic=33591.0 - Topic: [SOLVED] How to delete a button on an OnClick event
https://www.lazarusforum.de/viewtopic.php?p=118333 - [gelöst]Was tun bei: Maybe the component is processing an event?
This was caused by a complex call chain of miRecentFileExecute() -> OpenMap() -> RefreshRecentMenu() -> RefillRecentMenu(), which result in the sender menu item being removed.
In such cases, Application.ReleaseComponent() should be used.
https://forum.lazarus.freepascal.org/index.php?topic=33591.0 - Topic: [SOLVED] How to delete a button on an OnClick event
https://www.lazarusforum.de/viewtopic.php?p=118333 - [gelöst]Was tun bei: Maybe the component is processing an event?
src/editor/f_main.pas | patch | blob | history |
diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas
index e4e0643b38045f34c23e8ea78a81895c00965736..e2fdc20540eb336e1dd0f611588044788c4149bf 100644 (file)
--- a/src/editor/f_main.pas
+++ b/src/editor/f_main.pas
procedure TMainForm.miRecentFileExecute (Sender: TObject);
var
s, fn: AnsiString;
+ n: LongInt;
begin
- s := RecentFiles[(Sender as TMenuItem).Tag];
+ n := (Sender as TMenuItem).Tag;
+ s := RecentFiles[n];
fn := g_ExtractWadName(s);
if FileExists(fn) then
OpenMap(fn, g_ExtractFilePathName(s))
else
begin
menu.Delete(i);
- MI.Destroy();
+ Application.ReleaseComponent(MI);
end;
end;