-
Notifications
You must be signed in to change notification settings - Fork 16
Description
KillTimer requires a handle.
However it is called in places that may be triggered even if there is no handle yet (and the VTV or one of its parents may not even have a parent themself, and handle creation may be impossible)
Example
procedure TBaseVirtualTree.DoChange(Node: PVirtualNode);
begin
KillTimer(Handle, ChangeTimer);
Create a VTV in code, but do not set a parent yet, then trigger a change.
I propose to protect all KillTimer calls. Introducing a new Method KillTime(ID: ...)
. Checking for HandleAllocated can then be done within this, and the call with the handle can be done if safe.
For reference, the issue was discovered here https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41430
I have not tested it with this VTV here, but a glance at the code made me believe that it can happen with this VTV too.
For reference / if interested in syncing with related other VTV
https://github.com/TurboPack/VirtualTreeView/blob/master/Source/VirtualTrees.pas#L7039-L7044
has StopTimer
doing exactly this.