Skip to content

KillTimer needs protection "if HandleAllocated then" #35

@User4martin

Description

@User4martin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions