Recent

Author Topic: I think I found a bug in ldocktree.pas  (Read 873 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 822
I think I found a bug in ldocktree.pas
« on: May 22, 2025, 08:14:02 pm »
I think I found a bug. Below is an empty project with 1 panel and in the uses only uses ldockttree added. If you click on the panel, nothing happens. If you check the box so that the panel becomes a dock site and then click on the panel then you get an AV.

The av is caused in the class procedure
Code: Pascal  [Select][+][-]
  1. TDockHeader.PerformMouseDown(AControl: TControl;
  of Ldocktree.pas.

If I adjust this function as follows, the AV is gone

Code: Pascal  [Select][+][-]
  1. class procedure TDockHeader.PerformMouseDown(AControl: TControl;
  2.   APart: TLazDockHeaderPart);
  3. begin
  4.   if AControl = nil then Exit; // <----- new line added.
  5.   case APart of
  6.     ldhpAll, ldhpCaption:
  7.       // mouse down on not buttons => start drag
  8.       AControl.BeginDrag(False);
  9.   end;
  10. end;
  11.  

Is this a bug or am I overlooking something else?


The full sample code:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     CheckBox1 : TCheckBox;
  16.     Panel1 : TPanel;
  17.     procedure CheckBox1Change(Sender : TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1 : TForm1;
  26.  
  27. implementation
  28.  
  29. uses ldocktree;  // <-----------------here
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.CheckBox1Change(Sender : TObject);
  36. begin
  37.   Panel1.DockSite:= True; // When active this causes a AV when you click ont the panel.
  38. end;
  39.  
  40. end.
  41.  


Edit:  Lazarus 4.0
« Last Edit: May 22, 2025, 08:17:36 pm by Hansvb »

msintle

  • Sr. Member
  • ****
  • Posts: 324
Re: I think I found a bug in ldocktree.pas
« Reply #1 on: May 27, 2025, 01:29:37 pm »
Is there a way to fix this in an existing Lazarus installation?

Somehow updating the file is never picked up by the actual compile process, at least not without deleting other pre-compiled files first.

Hansvb

  • Hero Member
  • *****
  • Posts: 822
Re: I think I found a bug in ldocktree.pas
« Reply #2 on: May 27, 2025, 06:15:28 pm »
It is a bug and is fixed in the bugfix release. See
Quote
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41675

You can fix it now if you add the extra line in ldoctree.pas.
« Last Edit: May 27, 2025, 06:17:08 pm by Hansvb »

msintle

  • Sr. Member
  • ****
  • Posts: 324
Re: I think I found a bug in ldocktree.pas
« Reply #3 on: May 28, 2025, 02:02:09 pm »
It is a bug and is fixed in the bugfix release. See
Quote
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41675

You can fix it now if you add the extra line in ldoctree.pas.

Ah that works instantly, many thanks for letting me know!
« Last Edit: May 28, 2025, 02:03:43 pm by msintle »

n7800

  • Sr. Member
  • ****
  • Posts: 368
Re: I think I found a bug in ldocktree.pas
« Reply #4 on: May 29, 2025, 09:08:01 pm »
@Hansvb, thanks for the fixing. Next time please add a link to the issue if you created one.

Hansvb

  • Hero Member
  • *****
  • Posts: 822
Re: I think I found a bug in ldocktree.pas
« Reply #5 on: May 29, 2025, 09:33:59 pm »
Fine. This is the first time I've made an issue. Will try to think about it next time.  :)

 

TinyPortal © 2005-2018