Moves freeing TStrings from standard controls to the widgetset. Necessary for widgets with a native TStrings.

git-svn-id: trunk@17787 -
This commit is contained in:
sekelsenmat 2008-12-10 21:12:10 +00:00
parent abf11caaf2
commit 226434bc52
5 changed files with 38 additions and 3 deletions

View File

@ -78,7 +78,7 @@ begin
if FItems<>nil then begin
NewStrings.Assign(FItems);
// delete interface based list
FItems.Free;
TWSCustomComboBoxClass(WidgetSetClass).FreeItems(FItems);
end;
// and use the internal list
FItems:= NewStrings;

View File

@ -150,7 +150,7 @@ begin
AssignItemDataToCache(i, NewStrings.Records[i]);
// free the interface items list
FItems.Free;
TWSCustomListBoxClass(WidgetSetClass).FreeStrings(FItems);
// new item list is the internal item list
NewStrings.Sorted:=FSorted;
FItems:= NewStrings;

View File

@ -152,7 +152,9 @@ begin
// copy items (text+objects) from the interface items list
NewStrings.Assign(Lines);
FLines.Free;
// Delete the interface item list
TWSCustomMemoClass(WidgetSetClass).FreeStrings(Lines);
// new item list is the internal item list
FLines:= NewStrings;
end;

View File

@ -85,6 +85,7 @@ type
class procedure SetReadOnly(const ACustomComboBox: TCustomComboBox; NewReadOnly: boolean); override;}
class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override;
class procedure FreeItems(var AItems: TStrings); override;
// class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
end;
@ -151,6 +152,7 @@ type
{ class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override;
class procedure SetAlignment(const ACustomMemo: TCustomMemo; const AAlignment: TAlignment); override;}
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
class procedure FreeStrings(var AStrings: TStrings); override;
{ class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override;
class procedure SetWantReturns(const ACustomMemo: TCustomMemo; const NewWantReturns: boolean); override;
class procedure SetWantTabs(const ACustomMemo: TCustomMemo; const NewWantTabs: boolean); override;
@ -350,6 +352,11 @@ begin
Result := FComboBox.Items;
end;
class procedure TFpGuiWSCustomComboBox.FreeItems(var AItems: TStrings);
begin
end;
class procedure TFpGuiWSCustomComboBox.ShowHide(const AWinControl: TWinControl
);
begin
@ -597,6 +604,11 @@ begin
Result:=inherited GetStrings(ACustomMemo);
end;
class procedure TFpGuiWSCustomMemo.FreeStrings(var AStrings: TStrings);
begin
end;
class procedure TFpGuiWSCustomMemo.ShowHide(const AWinControl: TWinControl);
begin
inherited ShowHide(AWinControl);

View File

@ -89,6 +89,7 @@ type
class procedure SetReadOnly(const ACustomComboBox: TCustomComboBox; NewReadOnly: boolean); virtual;
class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; virtual;
class procedure FreeItems(var AItems: TStrings); virtual;
class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); virtual;
class function GetItemHeight(const ACustomComboBox: TCustomComboBox): Integer; virtual;
@ -112,6 +113,7 @@ type
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; virtual;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; virtual;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; virtual;
class procedure FreeStrings(var AStrings: TStrings); virtual;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; virtual;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); virtual;
@ -161,6 +163,7 @@ type
published
class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); virtual;
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; virtual;
class procedure FreeStrings(var AStrings: TStrings); virtual;
class procedure SetAlignment(const ACustomMemo: TCustomMemo; const AAlignment: TAlignment); virtual;
class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); virtual;
class procedure SetWantTabs(const ACustomMemo: TCustomMemo; const NewWantTabs: boolean); virtual;
@ -285,6 +288,12 @@ begin
Result := nil;
end;
class procedure TWSCustomListBox.FreeStrings(var AStrings: TStrings);
begin
AStrings.Free;
AStrings := nil;
end;
class function TWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer;
begin
Result := 0;
@ -398,6 +407,12 @@ begin
Result := nil;
end;
class procedure TWSCustomComboBox.FreeItems(var AItems: TStrings);
begin
AItems.Free;
AItems := nil;
end;
class procedure TWSCustomComboBox.Sort(const ACustomComboBox: TCustomComboBox;
AList: TStrings; IsSorted: boolean);
begin
@ -484,6 +499,12 @@ begin
Result := ACustomMemo.Lines; //use default if the WS has not defined any
end;
class procedure TWSCustomMemo.FreeStrings(var AStrings: TStrings);
begin
AStrings.Free;
AStrings := nil;
end;
class procedure TWSCustomMemo.SetAlignment(const ACustomMemo: TCustomMemo;
const AAlignment: TAlignment);
begin