Skip to content

Commit

Permalink
Fixed issue #656: Fixed memory leaks in Advanced Demo
Browse files Browse the repository at this point in the history
* Many of the forms were not using the event OnFreeNode to release node data.
  • Loading branch information
Sanjay Kanade authored and Sanjay Kanade committed Sep 20, 2016
1 parent afd4b9c commit e468ea2
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ V6.4: (under developement)
* Fixed #653: GetFirstVisibleChild/NoInit check for wrong node if IncludeFiltered=True
* Fixed #647: New option to set the way of selecting next cell for editing in grid mode
* Fixed #645: Can't link 64 bit VCL app with VirtualTreeView in C++ Builder 10.1 Berlin
* Fixed #656: Fixed memory leaks in Advanced Demo

V6.3: (17 May 2016)
* Added support for RAD Studio 10.1 Berlin
Expand Down
11 changes: 6 additions & 5 deletions Demos/Advanced/AlignDemo.dfm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
object AlignForm: TAlignForm
Left = 561
Top = 278
Width = 825
Height = 499
ClientHeight = 460
ClientWidth = 809
Color = clBtnFace
Constraints.MinWidth = 590
Font.Charset = ANSI_CHARSET
Expand All @@ -15,7 +15,7 @@ object AlignForm: TAlignForm
OnDestroy = FormDestroy
DesignSize = (
809
461)
460)
PixelsPerInch = 96
TextHeight = 16
object Label8: TLabel
Expand Down Expand Up @@ -126,6 +126,7 @@ object AlignForm: TAlignForm
TreeOptions.PaintOptions = [toHideFocusRect, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware]
TreeOptions.SelectionOptions = [toExtendedFocus, toMultiSelect]
OnFocusChanged = AlignTreeFocusChanged
OnFreeNode = AlignTreeFreeNode
OnPaintText = AlignTreePaintText
OnGetImageIndex = AlignTreeGetImageIndex
OnGetNodeDataSize = AlignTreeGetNodeDataSize
Expand Down Expand Up @@ -334,7 +335,7 @@ object AlignForm: TAlignForm
Left = 554
Top = 212
Bitmap = {
494C010102000400040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010102000400080010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000001000000001002000000000000010
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
Expand Down Expand Up @@ -479,7 +480,7 @@ object AlignForm: TAlignForm
Left = 556
Top = 244
Bitmap = {
494C010141004500040020002000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010141004500080020002000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000800000002002000001002000000000000040
0400000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
11 changes: 11 additions & 0 deletions Demos/Advanced/AlignDemo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ TAlignForm = class(TForm)
procedure LayoutComboChange(Sender: TObject);
procedure AlignTreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
procedure AlignTreeStateChange(Sender: TBaseVirtualTree; Enter, Leave: TVirtualTreeStates);
procedure AlignTreeFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
private
FArabicFont,
FHebrewFont: TFont;
Expand Down Expand Up @@ -617,4 +618,14 @@ procedure TAlignForm.AlignTreeStateChange(Sender: TBaseVirtualTree; Enter, Leave

//----------------------------------------------------------------------------------------------------------------------

procedure TAlignForm.AlignTreeFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: PAlignData;

begin
Data := Sender.GetNodeData(Node);
Finalize(Data^);
end;

end.
7 changes: 3 additions & 4 deletions Demos/Advanced/GeneralAbilitiesDemo.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ object GeneralForm: TGeneralForm
TreeOptions.PaintOptions = [toHideSelection, toHotTrack, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toShowVertGridLines, toThemeAware, toUseBlendedImages, toFullVertGridLines, toUseBlendedSelection]
TreeOptions.SelectionOptions = [toExtendedFocus, toMiddleClickSelect, toMultiSelect, toRightClickSelect]
TreeOptions.StringOptions = [toSaveCaptions, toShowStaticText, toAutoAcceptEditChange]
TreeOptions.EditOptions = toDefaultEdit
OnDragOver = VST2DragOver
OnFocusChanging = VST2FocusChanging
OnFreeNode = VST2FreeNode
OnPaintText = VST2PaintText
OnGetImageIndexEx = VST2GetImageIndexEx
OnGetNodeDataSize = VST2GetNodeDataSize
Expand Down Expand Up @@ -199,7 +199,6 @@ object GeneralForm: TGeneralForm
'Alpha blended rectangle')
TabOrder = 2
OnClick = RadioGroup2Click
ExplicitLeft = 13
end
object ThemeRadioGroup: TRadioGroup
AlignWithMargins = True
Expand Down Expand Up @@ -285,7 +284,7 @@ object GeneralForm: TGeneralForm
Left = 22
Top = 148
Bitmap = {
494C010112001300080010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C0101120013000C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000005000000001002000000000000050
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down Expand Up @@ -994,7 +993,7 @@ object GeneralForm: TGeneralForm
Left = 32
Top = 200
Bitmap = {
494C010151005400080018001800FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C0101510054000C0018001800FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
000000000000360000002800000060000000F8010000010020000000000000F4
0200000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
11 changes: 11 additions & 0 deletions Demos/Advanced/GeneralAbilitiesDemo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ TGeneralForm = class(TForm)
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: TImageIndex;
var ImageList: TCustomImageList);
procedure VST2FreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
end;

var
Expand Down Expand Up @@ -559,4 +560,14 @@ procedure TGeneralForm.VST2DragOver(Sender: TBaseVirtualTree; Source: TObject; S

//----------------------------------------------------------------------------------------------------------------------

procedure TGeneralForm.VST2FreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: PNodeData2;

begin
Data := Sender.GetNodeData(Node);
Finalize(data^);
end;

end.
9 changes: 5 additions & 4 deletions Demos/Advanced/PropertiesDemo.dfm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
object PropertiesForm: TPropertiesForm
Left = 397
Top = 294
Width = 637
Height = 421
ClientHeight = 382
ClientWidth = 621
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Expand All @@ -13,7 +13,7 @@ object PropertiesForm: TPropertiesForm
OnCreate = FormCreate
DesignSize = (
621
383)
382)
PixelsPerInch = 96
TextHeight = 16
object Label9: TLabel
Expand Down Expand Up @@ -75,6 +75,7 @@ object PropertiesForm: TPropertiesForm
OnChange = VST3Change
OnCreateEditor = VST3CreateEditor
OnEditing = VST3Editing
OnFreeNode = VST3FreeNode
OnPaintText = VST3PaintText
OnGetImageIndex = VST3GetImageIndex
OnInitChildren = VST3InitChildren
Expand Down Expand Up @@ -112,7 +113,7 @@ object PropertiesForm: TPropertiesForm
Left = 422
Top = 224
Bitmap = {
494C010112001300040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010112001300080010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000005000000001002000000000000050
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
11 changes: 11 additions & 0 deletions Demos/Advanced/PropertiesDemo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ TPropertiesForm = class(TForm)
var Result: Integer);
procedure RadioGroup1Click(Sender: TObject);
procedure VST3StateChange(Sender: TBaseVirtualTree; Enter, Leave: TVirtualTreeStates);
procedure VST3FreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
private
procedure WMStartEditing(var Message: TMessage); message WM_STARTEDITING;
end;
Expand Down Expand Up @@ -339,4 +340,14 @@ procedure TPropertiesForm.WMStartEditing(var Message: TMessage);

//----------------------------------------------------------------------------------------------------------------------

procedure TPropertiesForm.VST3FreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: PPropertyData;

begin
Data := Sender.GetNodeData(Node);
Finalize(Data^);
end;

end.
9 changes: 6 additions & 3 deletions Demos/Advanced/VisibilityDemo.dfm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
object VisibilityForm: TVisibilityForm
Left = 573
Top = 362
Width = 752
Height = 529
ClientHeight = 490
ClientWidth = 736
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Expand All @@ -15,7 +15,7 @@ object VisibilityForm: TVisibilityForm
OnShow = FormShow
DesignSize = (
736
491)
490)
PixelsPerInch = 96
TextHeight = 16
object Label17: TLabel
Expand Down Expand Up @@ -4164,6 +4164,7 @@ object VisibilityForm: TVisibilityForm
OnChange = VST2Change
OnCollapsed = VSTCollapsedExpanded
OnExpanded = VSTCollapsedExpanded
OnFreeNode = VST2FreeNode
OnInitChildren = VST2InitChildren
OnInitNode = VST1InitNode
OnScroll = VST2Scroll
Expand Down Expand Up @@ -8217,6 +8218,7 @@ object VisibilityForm: TVisibilityForm
OnChange = VST2Change
OnCollapsed = VSTCollapsedExpanded
OnExpanded = VSTCollapsedExpanded
OnFreeNode = VST3FreeNode
OnInitChildren = VST2InitChildren
OnInitNode = VST1InitNode
OnScroll = VST3Scroll
Expand Down Expand Up @@ -8277,6 +8279,7 @@ object VisibilityForm: TVisibilityForm
TabOrder = 0
TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScroll, toAutoScrollOnExpand, toAutoTristateTracking, toAutoHideButtons]
TreeOptions.SelectionOptions = [toMultiSelect]
OnFreeNode = VST1FreeNode
OnInitChildren = VST1InitChildren
OnInitNode = VST1InitNode
Columns = <>
Expand Down
36 changes: 36 additions & 0 deletions Demos/Advanced/VisibilityDemo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ TVisibilityForm = class(TForm)
var CellText: UnicodeString);
procedure FormShow(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure VST3FreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure VST2FreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure VST1FreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
private
FChanging: Boolean;
procedure HideNodes(Sender: TBaseVirtualTree; Node: PVirtualNode; Data: Pointer; var Abort: Boolean);
Expand Down Expand Up @@ -342,4 +345,37 @@ procedure TVisibilityForm.FormHide(Sender: TObject);

//----------------------------------------------------------------------------------------------------------------------

procedure TVisibilityForm.VST1FreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: PLinkData;
begin
Data := Sender.GetNodeData(Node);
Finalize(Data^);
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TVisibilityForm.VST2FreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: PLinkData;
begin
Data := Sender.GetNodeData(Node);
Finalize(Data^);
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TVisibilityForm.VST3FreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: PLinkData;

begin
Data := Sender.GetNodeData(Node);
Finalize(Data^);
end;


end.
Loading

0 comments on commit e468ea2

Please sign in to comment.