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) | ||
commit | 09c7e2fe60e25c431d1cea07282f471b8309d2c9 | |
tree | a66fe7d10102fbd519da8e8b84eaeff9eea43093 | tree | snapshot |
parent | dc621084d159f9313377df9c5ae3a3dad77b3e08 | commit | diff |
Fix LCLRefCount warning and possible use-after-free
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?
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?
src/editor/f_main.pas | diff | blob | history |