Access Violation in destroying form

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #71239
    freezerua
    Participant

    Hi,

    I found bug in TsButton.
    For reproducing you need to put TsButton on form, link TImageList to Images property, start and close application.
    Issue details:
    1. TsButton.Destroy do FreeAndNil(FCommonData);
    2. TsButton.Destroy – goes into inherited Destroy;
    3. TCustomButton.Destroy sets Images := nil;
    4. TCustomButton.SetImages calls UpdateImageList;
    5. TsButton.UpdateImageList calls FCommonData.Invalidate, but we already destroy it and it’s nil now. So we get AV.

    Solution proposal:

    procedure TsButton.UpdateImageList;
    begin
      if (Self <> nil) and not (csDestroying in Self.ComponentState) then 
      begin
        inherited;
        FCommonData.Invalidate;
      end;
    end;

    Delphi 11.3 CE, Windows 11.

    Attachments:
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.