diff options
-rw-r--r-- | examples/gui/filedialog/filedialog.lpi | 3 | ||||
-rw-r--r-- | examples/gui/fontselect/fontselect.lpi | 3 | ||||
-rw-r--r-- | examples/gui/gauges/gaugetest.lpi | 3 | ||||
-rw-r--r-- | examples/gui/gridtest/gridtest.lpi | 3 | ||||
-rw-r--r-- | examples/gui/imgtest/bitmaptest.lpi | 2 | ||||
-rw-r--r-- | examples/gui/stdimages/stdimglist.lpi | 5 | ||||
-rw-r--r-- | examples/gui/treeviewtest/treeviewtest.lpr | 9 | ||||
-rw-r--r-- | src/gui/gui_combobox.pas | 1 | ||||
-rw-r--r-- | src/gui/gui_tree.pas | 87 |
9 files changed, 87 insertions, 29 deletions
diff --git a/examples/gui/filedialog/filedialog.lpi b/examples/gui/filedialog/filedialog.lpi index 93c2d7b0..9908bf52 100644 --- a/examples/gui/filedialog/filedialog.lpi +++ b/examples/gui/filedialog/filedialog.lpi @@ -46,7 +46,8 @@ <Generate Value="Faster"/> </CodeGeneration> <Other> - <CustomOptions Value="-FUunits"/> + <CustomOptions Value="-FUunits +"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/fontselect/fontselect.lpi b/examples/gui/fontselect/fontselect.lpi index d23df471..d97b57fa 100644 --- a/examples/gui/fontselect/fontselect.lpi +++ b/examples/gui/fontselect/fontselect.lpi @@ -46,7 +46,8 @@ <Generate Value="Faster"/> </CodeGeneration> <Other> - <CustomOptions Value="-FUunits"/> + <CustomOptions Value="-FUunits +"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/gauges/gaugetest.lpi b/examples/gui/gauges/gaugetest.lpi index 7c26a800..0baac1c7 100644 --- a/examples/gui/gauges/gaugetest.lpi +++ b/examples/gui/gauges/gaugetest.lpi @@ -50,7 +50,8 @@ <Generate Value="Faster"/> </CodeGeneration> <Other> - <CustomOptions Value="-FUunits"/> + <CustomOptions Value="-FUunits +"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/gridtest/gridtest.lpi b/examples/gui/gridtest/gridtest.lpi index c22c0856..0860255a 100644 --- a/examples/gui/gridtest/gridtest.lpi +++ b/examples/gui/gridtest/gridtest.lpi @@ -46,7 +46,8 @@ <Generate Value="Faster"/> </CodeGeneration> <Other> - <CustomOptions Value="-FUunits"/> + <CustomOptions Value="-FUunits +"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/imgtest/bitmaptest.lpi b/examples/gui/imgtest/bitmaptest.lpi index de1157a5..c318e155 100644 --- a/examples/gui/imgtest/bitmaptest.lpi +++ b/examples/gui/imgtest/bitmaptest.lpi @@ -2,7 +2,7 @@ <CONFIG> <ProjectOptions> <PathDelim Value="/"/> - <Version Value="5"/> + <Version Value="6"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> diff --git a/examples/gui/stdimages/stdimglist.lpi b/examples/gui/stdimages/stdimglist.lpi index 1d6f96bb..613a4a70 100644 --- a/examples/gui/stdimages/stdimglist.lpi +++ b/examples/gui/stdimages/stdimglist.lpi @@ -2,7 +2,7 @@ <CONFIG> <ProjectOptions> <PathDelim Value="/"/> - <Version Value="5"/> + <Version Value="6"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> @@ -45,7 +45,8 @@ <Generate Value="Faster"/> </CodeGeneration> <Other> - <CustomOptions Value="-FUunits"/> + <CustomOptions Value="-FUunits +"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/treeviewtest/treeviewtest.lpr b/examples/gui/treeviewtest/treeviewtest.lpr index 562ca8bb..68fb9f91 100644 --- a/examples/gui/treeviewtest/treeviewtest.lpr +++ b/examples/gui/treeviewtest/treeviewtest.lpr @@ -75,9 +75,12 @@ var begin fpgApplication.Initialize; frm := TMainForm.Create(nil); - frm.Show; - fpgApplication.Run; - frm.Free; + try + frm.Show; + fpgApplication.Run; + finally + frm.Free; + end; end; begin diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas index 82a10afa..91e422fb 100644 --- a/src/gui/gui_combobox.pas +++ b/src/gui/gui_combobox.pas @@ -484,6 +484,7 @@ end; destructor TfpgAbstractComboBox.Destroy; begin FItems.Free; + FFont.Free; inherited Destroy; end; diff --git a/src/gui/gui_tree.pas b/src/gui/gui_tree.pas index b1328b14..0565f0fd 100644 --- a/src/gui/gui_tree.pas +++ b/src/gui/gui_tree.pas @@ -167,6 +167,8 @@ type procedure HScrollbarScroll(Sender: TObject; position: integer); procedure UpdateScrollbars; procedure ResetScrollbar; + procedure ClearColumnLeft; + procedure FreeAllTreeNodes; protected FColumnLeft: TList; procedure HandleResize(awidth, aheight: TfpgCoord); override; @@ -186,6 +188,7 @@ type function StepToRoot(aNode: TfpgTreeNode): integer; public constructor Create(AOwner: TComponent); override; + destructor Destroy; override; procedure SetColumnWidth(AIndex, AWidth: word); function GetColumnWidth(AIndex: word): word; // the width of a column - aIndex of the rootnode = 0 property Font: TfpgFont read FFont; @@ -317,7 +320,12 @@ destructor TfpgTreeNode.Destroy; begin if FParent <> nil then FParent.UnregisterSubNode(self); - FData := nil; + FData := nil; + FParent := nil; + FNext := nil; + FPrev := nil; + FFirstSubNode := nil; + FLastSubNode := nil; inherited Destroy; end; @@ -862,8 +870,6 @@ begin end; function TfpgTreeview.GetColumnLeft(AIndex: integer): integer; -var - AColumnLeft: PColumnLeft; begin if FColumnLeft = nil then PreCalcColumnLeft; @@ -873,15 +879,9 @@ begin else begin if AIndex > FColumnLeft.Count - 1 then - begin - AColumnLeft := FColumnLeft[FColumnLeft.Count - 1]; - result := AColumnLeft^; - end + result := PColumnLeft(FColumnLeft[FColumnLeft.Count - 1])^ else - begin - AColumnLeft := FColumnLeft[AIndex]; - result := AColumnLeft^; - end; + result := PColumnLeft(FColumnLeft[AIndex])^; end; end; @@ -926,14 +926,10 @@ begin writeln('TfpgTreeView.PreCalcColumnWidth'); {$ENDIf} if FColumnLeft = nil then - FColumnLeft := TList.Create - else - FColumnLeft.Clear; - for ACounter := 0 to FColumnLeft.Count - 1 do // Freeing Memory - begin - AColumnLeft := FColumnLeft[ACounter]; - Dispose(AColumnLeft); - end; + FColumnLeft := TList.Create; + + ClearColumnLeft; // Freeing memory + Aleft := 0; for ACounter := 1 to RootNode.GetMaxDepth do begin @@ -988,6 +984,47 @@ begin FHScrollbar.SetPosition(1, Height - 19, Width - 2, 18); end; +procedure TfpgTreeView.ClearColumnLeft; +var + i: integer; + AColumnLeft: PColumnLeft; +begin + for i := 0 to FColumnLeft.Count - 1 do // Freeing Memory + begin + AColumnLeft := FColumnLeft[i]; + Dispose(AColumnLeft); + end; + FColumnLeft.Clear; +end; + +procedure TfpgTreeView.FreeAllTreeNodes; +var + n: TfpgTreeNode; + i: integer; + list: TList; +begin + list := TList.Create; + n := RootNode.FirstSubNode; + list.Add(n); + + while n <> nil do + begin + // todo: this only frees of the first level of nodes!!!! + n := n.next; + list.Add(n); + end; + +// writeln('NodeCount = ', list.Count); + while list.Count > 0 do + begin + n := TfpgTreeNode(list.Last); + list.Remove(n); + n.Free; + end; + list.Clear; + list.Free; +end; + procedure TfpgTreeview.HandleResize(awidth, aheight: TfpgCoord); begin {$IFDEF DEBUG} @@ -1661,6 +1698,18 @@ begin FScrollWheelDelta := 15; end; +destructor TfpgTreeView.Destroy; +var + i: integer; +begin + ClearColumnLeft; + FFont.Free; + + FreeAllTreeNodes; + + inherited Destroy; +end; + procedure TfpgTreeview.SetColumnWidth(AIndex, AWidth: word); var h: PfpgTreeColumnWidth; |