Skip to content

Exception in SetDefaultNodeHeight when Parent = nil due to unconditional HandleNeeded() call #1366

Description

@stephane128

Calling TBaseVirtualTree.SetDefaultNodeHeight can raise an exception when the control has no parent assigned (Parent = nil).

This happens because HandleNeeded() is invoked unconditionally when toAutoChangeScale is enabled. However, HandleNeeded() internally requires a valid parent window handle, which is not available when the control is not yet inserted into a parent.

Current Implementation:

if toAutoChangeScale in TreeOptions.AutoOptions then
  HandleNeeded();

Proposed Fix:

Add a guard to ensure Parent <> nil before calling HandleNeeded():

if (Parent <> nil) and (toAutoChangeScale in TreeOptions.AutoOptions) then
  HandleNeeded();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions