mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 11:58:12 +02:00
fixed buffer overrun and added several checks
git-svn-id: trunk@3651 -
This commit is contained in:
parent
d527baa868
commit
860db3b542
@ -66,6 +66,7 @@ type
|
||||
public
|
||||
{ public declarations }
|
||||
constructor Create(AOwner : TComponent); override;
|
||||
destructor Destroy; override;
|
||||
property Columns: TListColumns read FColumns write SetColumns;
|
||||
end;
|
||||
|
||||
@ -254,6 +255,12 @@ Begin
|
||||
FSelectedIndex:= -1;
|
||||
end;
|
||||
|
||||
destructor TColumnDlg.Destroy;
|
||||
begin
|
||||
FreeAndNil(FColumns);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
procedure TColumnDlg.Button1OnClick(sender : TObject);
|
||||
var
|
||||
|
@ -157,7 +157,6 @@ type
|
||||
function GetIndex : Integer;
|
||||
protected
|
||||
Procedure ItemChanged(sender : TObject); //called by the onchange of the tstringlist in TListItem
|
||||
|
||||
public
|
||||
constructor Create(AOwner : TListItems);
|
||||
destructor Destroy; override;
|
||||
@ -248,6 +247,7 @@ type
|
||||
function Add: TListColumn;
|
||||
property Owner: TCustomListView read FOwner;
|
||||
property Items[const AIndex: Integer]: TListColumn read GetItem write SetItem; default;
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
end;
|
||||
|
||||
TItemChange = (ctText, ctImage, ctState);
|
||||
@ -1699,6 +1699,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.59 2002/11/18 13:38:44 mattias
|
||||
fixed buffer overrun and added several checks
|
||||
|
||||
Revision 1.58 2002/11/13 18:21:04 lazarus
|
||||
MG: added TListItems.Clear
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
{------------------------------------------------------------------------------
|
||||
TCustomListView Constructor
|
||||
------------------------------------------------------------------------------}
|
||||
constructor TCustomListView.Create(Aowner: TComponent);
|
||||
constructor TCustomListView.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FColumns := TListColumns.Create(self);
|
||||
@ -85,7 +85,8 @@ begin
|
||||
// NM_CUSTOMDRAW:
|
||||
// LVN_BEGINDRAG:
|
||||
LVN_DELETEITEM: begin
|
||||
//don'tcall delete yet, there is no sulution available when we have deleted the item first
|
||||
// don't call delete yet,
|
||||
// there is no solution available when we have deleted the item first
|
||||
Item := Items[nm^.iItem];
|
||||
DoDeletion(Item)
|
||||
end;
|
||||
@ -152,9 +153,9 @@ end;
|
||||
procedure TCustomListView.InitializeWnd;
|
||||
begin
|
||||
inherited InitializeWnd;
|
||||
CNSendMessage(LM_SETPROPERTIES,self,nil);
|
||||
CNSendMessage(LM_SETPROPERTIES,Self,nil);
|
||||
if FSelected<>nil then
|
||||
CNSendMessage(LM_LV_SELECTITEM,self,FSelected);
|
||||
CNSendMessage(LM_LV_SELECTITEM,Self,FSelected);
|
||||
end;
|
||||
|
||||
procedure TCustomListView.Loaded;
|
||||
@ -252,7 +253,10 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetColumns(const AValue: TListColumns);
|
||||
begin
|
||||
if AValue=FColumns then exit;
|
||||
FColumns.Assign(AValue);
|
||||
if ([csDesigning,csLoading,csReading]*ComponentState=[csDesigning]) then
|
||||
OwnerFormDesignerModified(Self);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -294,9 +298,9 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
destructor TCustomListView.Destroy;
|
||||
begin
|
||||
Columns.Free;
|
||||
FImageChangeLink.Free;
|
||||
FListItems.Free;
|
||||
FreeThenNil(FColumns);
|
||||
FreeThenNil(FImageChangeLink);
|
||||
FreeThenNil(FListItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -314,11 +318,12 @@ begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView GetSelection }
|
||||
{ TCustomListView GetSelection }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.EndUpdate;
|
||||
begin
|
||||
if FUpdateCount=0 then exit;
|
||||
if FUpdateCount=0 then
|
||||
RaiseGDBException('TCustomListView.EndUpdate FUpdateCount=0');
|
||||
dec(FUpdateCount);
|
||||
if FUpdateCount>0 then exit;
|
||||
DoUpdate;
|
||||
@ -330,7 +335,7 @@ begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView GetSelection }
|
||||
{ TCustomListView GetSelection }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TCustomListView.GetSelection: TListItem;
|
||||
begin
|
||||
@ -338,7 +343,7 @@ begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetSelection }
|
||||
{ TCustomListView SetSelection }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetSelection(const AValue: TListItem);
|
||||
begin
|
||||
@ -351,15 +356,17 @@ end;
|
||||
|
||||
procedure TCustomListView.SetMultiSelect(const AValue: Boolean);
|
||||
begin
|
||||
if MultiSelect <> AValue then
|
||||
Begin
|
||||
if AValue then
|
||||
Include(FStates,lvMultiSelect)
|
||||
else
|
||||
Exclude(FStates,lvMultiSelect);
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then
|
||||
Include(FStates,lvUpdateNeeded);
|
||||
CNSendMessage(LM_SETPROPERTIES,self,nil);
|
||||
if MultiSelect = AValue then exit;
|
||||
if AValue then
|
||||
Include(FStates,lvMultiSelect)
|
||||
else
|
||||
Exclude(FStates,lvMultiSelect);
|
||||
if FUpdateCount>0 then
|
||||
Include(FStates,lvUpdateNeeded)
|
||||
else begin
|
||||
//notify the interface...
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
CNSendMessage(LM_SETPROPERTIES,Self,nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -384,7 +391,7 @@ end;
|
||||
|
||||
Procedure TCustomListView.ImageChanged(Sender : TObject);
|
||||
begin
|
||||
if csDestroying in Componentstate Then Exit;
|
||||
if csDestroying in ComponentState Then Exit;
|
||||
if FUpdateCount>0 then
|
||||
Include(FStates,lvUpdateNeeded)
|
||||
else begin
|
||||
@ -396,9 +403,13 @@ end;
|
||||
|
||||
procedure TCustomListView.SetScrollBars(const Value: TScrollStyle);
|
||||
begin
|
||||
if (FScrollBars <> Value) then
|
||||
begin
|
||||
FScrollBars := Value;
|
||||
if (FScrollBars = Value) then exit;
|
||||
FScrollBars := Value;
|
||||
if FUpdateCount>0 then
|
||||
Include(FStates,lvUpdateNeeded)
|
||||
else begin
|
||||
//notify the interface...
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
RecreateWnd;
|
||||
UpdateScrollBars;
|
||||
end;
|
||||
@ -545,6 +556,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.24 2002/11/18 13:38:44 mattias
|
||||
fixed buffer overrun and added several checks
|
||||
|
||||
Revision 1.23 2002/10/09 11:46:04 lazarus
|
||||
MG: fixed loading TListView from stream
|
||||
|
||||
|
@ -37,6 +37,8 @@ end;
|
||||
function TNBPages.Get(Index: Integer): String;
|
||||
begin
|
||||
//writeln('TNBPages.Get Index=',Index);
|
||||
if (Index<0) or (Index>=fPageList.Count) then
|
||||
RaiseGDBException('TNBPages.Get Index out of bounds');
|
||||
Result := TPage(fPageList[Index]).Caption;
|
||||
end;
|
||||
|
||||
@ -53,6 +55,8 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TNBPages.GetObject(Index: Integer): TObject;
|
||||
begin
|
||||
if (Index<0) or (Index>=fPageList.Count) then
|
||||
RaiseGDBException('TNBPages.GetObject Index out of bounds');
|
||||
Result := TPage(fPageList[Index]);
|
||||
end;
|
||||
|
||||
@ -63,6 +67,8 @@ procedure TNBPages.Put(Index: Integer; const S: String);
|
||||
var
|
||||
Msg: TLMNotebookEvent;
|
||||
begin
|
||||
if (Index<0) or (Index>=fPageList.Count) then
|
||||
RaiseGDBException('TNBPages.Put Index out of bounds');
|
||||
TPage(fPageList[Index]).Caption := S;
|
||||
|
||||
if (FNoteBook.HandleAllocated)
|
||||
@ -464,8 +470,6 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TCustomNotebook.GetPageIndex: Integer;
|
||||
begin
|
||||
//we don't have to query the control.
|
||||
// FPageindex should track this along with the pagechanged handler.
|
||||
Result := fPageIndex;
|
||||
end;
|
||||
|
||||
@ -495,6 +499,8 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TCustomNotebook.GetPage(aIndex: Integer): TPage;
|
||||
begin
|
||||
if (aIndex<0) or (aIndex>=fPageList.Count) then
|
||||
RaiseGDBException('TCustomNotebook.GetPage Index out of bounds');
|
||||
Result := TPage(fPageList.Items[aIndex]);
|
||||
end;
|
||||
|
||||
@ -697,6 +703,9 @@ end;}
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.26 2002/11/18 13:38:44 mattias
|
||||
fixed buffer overrun and added several checks
|
||||
|
||||
Revision 1.25 2002/11/09 15:02:07 lazarus
|
||||
MG: fixed LM_LVChangedItem, OnShowHint, small bugs
|
||||
|
||||
|
@ -20,6 +20,20 @@
|
||||
function TListColumns.Add: TListColumn;
|
||||
Begin
|
||||
Result := TListColumn(inherited Add);
|
||||
if (Owner<>nil)
|
||||
and ([csDesigning,csLoading,csReading]*Owner.ComponentState=[csDesigning])
|
||||
then
|
||||
OwnerFormDesignerModified(Owner);
|
||||
end;
|
||||
|
||||
procedure TListColumns.Assign(Source: TPersistent);
|
||||
begin
|
||||
if (Source=nil) or (Source=Self) then exit;
|
||||
inherited Assign(Source);
|
||||
if (Owner<>nil)
|
||||
and ([csDesigning,csLoading,csReading]*Owner.ComponentState=[csDesigning])
|
||||
then
|
||||
OwnerFormDesignerModified(Owner);
|
||||
end;
|
||||
|
||||
constructor TListColumns.Create(AOwner: TCustomListView);
|
||||
@ -40,15 +54,18 @@ end;
|
||||
|
||||
procedure TListColumns.Update(AnItem: TCollectionItem);
|
||||
begin
|
||||
//TODO: Optimize implementation by invoking individual upadates instead of
|
||||
//TODO: Optimize implementation by invoking individual updates instead of
|
||||
// recreating window
|
||||
if FOwner <>nil
|
||||
then FOwner.ColumnsChanged;
|
||||
if FOwner <>nil then
|
||||
FOwner.ColumnsChanged;
|
||||
end;
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.5 2002/11/18 13:38:44 mattias
|
||||
fixed buffer overrun and added several checks
|
||||
|
||||
Revision 1.4 2002/10/09 11:46:05 lazarus
|
||||
MG: fixed loading TListView from stream
|
||||
|
||||
|
@ -88,7 +88,7 @@ begin
|
||||
if FOwner <> nil
|
||||
then FOwner.ItemDeleted(Self);
|
||||
|
||||
SubItems.Free;
|
||||
FreeThenNil(FSubItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -97,7 +97,7 @@ begin
|
||||
if AValue <> FImageIndex then
|
||||
Begin
|
||||
FImageIndex := AValue;
|
||||
ItemChanged(self);
|
||||
ItemChanged(Self);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -119,6 +119,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.11 2002/11/18 13:38:44 mattias
|
||||
fixed buffer overrun and added several checks
|
||||
|
||||
Revision 1.10 2002/05/10 06:05:53 lazarus
|
||||
MG: changed license to LGPL
|
||||
|
||||
|
@ -108,7 +108,7 @@ destructor TListItems.Destroy;
|
||||
begin
|
||||
while FItems.Count>0 do
|
||||
TListItem(FItems[0]).Free;
|
||||
FItems.Free;
|
||||
FreeThenNil(FItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -145,6 +145,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.15 2002/11/18 13:38:44 mattias
|
||||
fixed buffer overrun and added several checks
|
||||
|
||||
Revision 1.14 2002/11/13 18:21:04 lazarus
|
||||
MG: added TListItems.Clear
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user