It looks like you're new here. If you want to get involved, click one of these buttons!
It crashes in finalization as HookList has some TCtlHooks referencing controls that are deleted.
In TElHook.SetActive(false), the FCtlHooks.Remove fix method from LMDHookComponent doesn't work because ElHook.TCtlHook.HookWndProc may be on the call stack, so you don't want to free its instance data too early. Instead you could set CH.FControl to nil (as below), which doesn't crash but the list will grow until the program exits and finalization runs.
ElHook.pas, SetActive:
if HookList <> nil then
begin
CH := HookList.GetCtlHook(FControl);
if CH <> nil then
begin
CH.RemoveHook(Self);
if CH.FHooks.Count = 0 then
begin
// HookList.FCtlHooks.Remove(CH); //crashes further down call stack
CH.FControl := nil; // clear the control, list grows forever?
end
end;
end;
Comments