Commit d969149f authored by Juha Manninen's avatar Juha Manninen
Browse files

LazControls: In FilterEdits check everywhere if the associated control exists. Issue #32282.

git-svn-id: trunk@55673 -
parent c0c164a9
......@@ -123,14 +123,14 @@ end;
procedure TListFilterEdit.MoveEnd(ASelect: Boolean);
begin
if fFilteredListbox.Items.Count > 0 then
MoveTo(fFilteredListbox.Items.Count-1, ASelect);
if (fFilteredListbox = nil) or (fFilteredListbox.Count = 0) then Exit;
MoveTo(fFilteredListbox.Items.Count-1, ASelect);
end;
procedure TListFilterEdit.MoveHome(ASelect: Boolean);
begin
if fFilteredListbox.Items.Count > 0 then
MoveTo(0, ASelect);
if (fFilteredListbox = nil) or (fFilteredListbox.Count = 0) then Exit;
MoveTo(0, ASelect);
end;
function TListFilterEdit.GetDefaultGlyph: TBitmap;
......@@ -253,7 +253,7 @@ procedure TListFilterEdit.MoveNext(ASelect: Boolean);
var
i: Integer;
begin
if fFilteredListbox.Count = 0 then Exit;
if (fFilteredListbox = nil) or (fFilteredListbox.Count = 0) then Exit;
if (fFilteredListbox.ItemIndex=0) and not fFilteredListbox.Selected[0] then
i := 0
else
......@@ -267,7 +267,7 @@ procedure TListFilterEdit.MovePrev(ASelect: Boolean);
var
i: Integer;
begin
if fFilteredListbox.Count = 0 then Exit;
if (fFilteredListbox = nil) or (fFilteredListbox.Count = 0) then Exit;
i := fFilteredListbox.ItemIndex - 1;
if i < 0 then
i := 0;
......@@ -278,8 +278,7 @@ procedure TListFilterEdit.MovePageDown(ASelect: Boolean);
var
i, ih: Integer;
begin
if fFilteredListbox.Items.Count = 0 then
Exit;
if (fFilteredListbox = nil) or (fFilteredListbox.Items.Count = 0) then Exit;
ih := fFilteredListbox.ItemHeight;
if ih = 0 then //fFilteredListbox.ItemHeight is always zero. Why?
ih := 22;
......@@ -293,8 +292,7 @@ procedure TListFilterEdit.MovePageUp(ASelect: Boolean);
var
i, ih: Integer;
begin
if fFilteredListbox.Items.Count = 0 then
Exit;
if (fFilteredListbox = nil) or (fFilteredListbox.Items.Count = 0) then Exit;
ih := fFilteredListbox.ItemHeight;
if ih = 0 then
ih := 22;
......
......@@ -195,15 +195,13 @@ end;
procedure TListViewFilterEdit.MoveEnd(ASelect: Boolean);
begin
if fFilteredListview.Items.Count = 0 then
Exit;
if (fFilteredListview = nil) or (fFilteredListview.Items.Count = 0) then Exit;
MoveTo(fFilteredListview.Items.Count-1, ASelect);
end;
procedure TListViewFilterEdit.MoveHome(ASelect: Boolean);
begin
if fFilteredListview.Items.Count = 0 then
Exit;
if (fFilteredListview = nil) or (fFilteredListview.Items.Count = 0) then Exit;
MoveTo(0, ASelect);
end;
......@@ -227,8 +225,7 @@ procedure TListViewFilterEdit.ApplyFilterCore;
var
i: Integer;
begin
if fFilteredListview = nil then
exit;
if fFilteredListview = nil then exit;
fFilteredListview.Clear;
fFilteredListview.Items.BeginUpdate;
for i:=0 to fFilteredData.Count-1 do
......@@ -241,8 +238,7 @@ procedure TListViewFilterEdit.StoreSelection;
var
i: Integer;
begin
if fFilteredListview = nil then
exit;
if fFilteredListview = nil then exit;
fSelectionList.Clear;
if fFilteredListview.SelCount > 0 then
for i := 0 to fFilteredListview.Items.Count-1 do
......@@ -254,7 +250,7 @@ procedure TListViewFilterEdit.RestoreSelection;
var
i: Integer;
begin
if fSelectionList.Count > 0 then
if (fSelectionList.Count > 0) and Assigned(fFilteredListview) then
for i := 0 to fFilteredListview.Items.Count-1 do
if fSelectionList.IndexOf(fFilteredListview.Items[i].Caption) > -1 then
fFilteredListview.Items[i].Selected:=True;
......@@ -264,7 +260,7 @@ procedure TListViewFilterEdit.MoveNext(ASelect: Boolean);
var
i: Integer;
begin
if fFilteredListview.Items.Count = 0 then Exit;
if (fFilteredListview = nil) or (fFilteredListview.Items.Count = 0) then Exit;
i := GetLastSelectedIndex + 1;
if i >= fFilteredListview.Items.Count then
i := fFilteredListview.Items.Count-1;
......@@ -275,8 +271,7 @@ procedure TListViewFilterEdit.MovePageDown(ASelect: Boolean);
var
I: Integer;
begin
if fFilteredListview.Items.Count = 0 then
Exit;
if (fFilteredListview = nil) or (fFilteredListview.Items.Count = 0) then Exit;
I := GetLastSelectedIndex + fFilteredListview.VisibleRowCount;
if (I < 0) or (I >= fFilteredListview.Items.Count) then
I := fFilteredListview.Items.Count-1;
......@@ -287,8 +282,7 @@ procedure TListViewFilterEdit.MovePageUp(ASelect: Boolean);
var
I: Integer;
begin
if fFilteredListview.Items.Count = 0 then
Exit;
if (fFilteredListview = nil) or (fFilteredListview.Items.Count = 0) then Exit;
I := GetLastSelectedIndex - fFilteredListview.VisibleRowCount;
if (I < 0) or (I >= fFilteredListview.Items.Count) then
I := 0;
......@@ -299,7 +293,7 @@ procedure TListViewFilterEdit.MovePrev(ASelect: Boolean);
var
i: Integer;
begin
if fFilteredListview.Items.Count = 0 then Exit;
if (fFilteredListview = nil) or (fFilteredListview.Items.Count = 0) then Exit;
i := GetLastSelectedIndex - 1;
if i < 0 then
i := 0;
......
......@@ -603,12 +603,14 @@ end;
procedure TTreeFilterEdit.MoveEnd(ASelect: Boolean);
begin
fFilteredTreeview.MoveEnd(ASelect);
if Assigned(fFilteredTreeview) then
fFilteredTreeview.MoveEnd(ASelect);
end;
procedure TTreeFilterEdit.MoveHome(ASelect: Boolean);
begin
fFilteredTreeview.MoveHome(ASelect);
if Assigned(fFilteredTreeview) then
fFilteredTreeview.MoveHome(ASelect);
end;
function TTreeFilterEdit.GetCleanBranch(ARootNode: TTreeNode): TTreeFilterBranch;
......@@ -642,22 +644,26 @@ end;
procedure TTreeFilterEdit.MoveNext(ASelect: Boolean);
begin
fFilteredTreeview.MoveToNextNode(ASelect);
if Assigned(fFilteredTreeview) then
fFilteredTreeview.MoveToNextNode(ASelect);
end;
procedure TTreeFilterEdit.MovePageDown(ASelect: Boolean);
begin
fFilteredTreeview.MovePageDown(ASelect);
if Assigned(fFilteredTreeview) then
fFilteredTreeview.MovePageDown(ASelect);
end;
procedure TTreeFilterEdit.MovePageUp(ASelect: Boolean);
begin
fFilteredTreeview.MovePageUp(ASelect);
if Assigned(fFilteredTreeview) then
fFilteredTreeview.MovePageUp(ASelect);
end;
procedure TTreeFilterEdit.MovePrev(ASelect: Boolean);
begin
fFilteredTreeview.MoveToPrevNode(ASelect);
if Assigned(fFilteredTreeview) then
fFilteredTreeview.MoveToPrevNode(ASelect);
end;
function TTreeFilterEdit.ReturnKeyHandled: Boolean;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment