UPD: Add some const modifiers. Remove const from TFileView.SetFileFilter because it assigns the string parameter to a non-local string. If FFileFilter is passed as the parameter but modified before the assignment it will be dereferenced causing a crash.

UPD: Remove UpdateView call on filter change, it is not needed.
This commit is contained in:
cobines 2012-03-01 13:54:24 +00:00
commit 8d3169bc9b
4 changed files with 13 additions and 16 deletions

View file

@ -21,8 +21,8 @@ type
Items: TQuickSearchItems;
end;
TOnChangeSearch = procedure(Sender: TObject; ASearchText: UTF8String; ASearchOptions: TQuickSearchOptions; Direction: TQuickSearchDirection = qsdNone) of Object;
TOnChangeFilter = procedure(Sender: TObject; AFilterText: UTF8String; AFilterOptions: TQuickSearchOptions) of Object;
TOnChangeSearch = procedure(Sender: TObject; ASearchText: UTF8String; const ASearchOptions: TQuickSearchOptions; Direction: TQuickSearchDirection = qsdNone) of Object;
TOnChangeFilter = procedure(Sender: TObject; AFilterText: UTF8String; const AFilterOptions: TQuickSearchOptions) of Object;
TOnExecute = procedure(Sender: TObject) of Object;
TOnHide = procedure(Sender: TObject) of Object;

View file

@ -234,8 +234,8 @@ type
procedure edtRenameKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure quickSearchChangeSearch(Sender: TObject; ASearchText: UTF8String; ASearchOptions: TQuickSearchOptions; ASearchDirection: TQuickSearchDirection);
procedure quickSearchChangeFilter(Sender: TObject; AFilterText: UTF8String; AFilterOptions: TQuickSearchOptions);
procedure quickSearchChangeSearch(Sender: TObject; ASearchText: UTF8String; const ASearchOptions: TQuickSearchOptions; ASearchDirection: TQuickSearchDirection);
procedure quickSearchChangeFilter(Sender: TObject; AFilterText: UTF8String; const AFilterOptions: TQuickSearchOptions);
procedure quickSearchExecute(Sender: TObject);
procedure quickSearchHide(Sender: TObject);
@ -1692,14 +1692,14 @@ begin
end;
end;
procedure TColumnsFileView.quickSearchChangeSearch(Sender: TObject; ASearchText: UTF8String; ASearchOptions: TQuickSearchOptions; ASearchDirection: TQuickSearchDirection);
procedure TColumnsFileView.quickSearchChangeSearch(Sender: TObject; ASearchText: UTF8String; const ASearchOptions: TQuickSearchOptions; ASearchDirection: TQuickSearchDirection);
begin
SetActive(True);
SearchFile(ASearchText, ASearchOptions, ASearchDirection);
end;
procedure TColumnsFileView.quickSearchChangeFilter(Sender: TObject; AFilterText: UTF8String; AFilterOptions: TQuickSearchOptions);
procedure TColumnsFileView.quickSearchChangeFilter(Sender: TObject; AFilterText: UTF8String; const AFilterOptions: TQuickSearchOptions);
begin
SetActive(True);
@ -1711,9 +1711,6 @@ begin
lblFilter.Caption := Format('(%s: %s)', [rsFilterStatus, AFilterText]);
lblFilter.Visible := Filtered;
// force update
UpdateView;
end;
procedure TColumnsFileView.quickSearchExecute(Sender: TObject);

View file

@ -335,7 +335,7 @@ type
procedure GoToPrevHistory;
procedure GoToNextHistory;
procedure SetFileFilter(const NewFilter: String; NewFilterOptions: TQuickSearchOptions);
procedure SetFileFilter(NewFilter: String; NewFilterOptions: TQuickSearchOptions);
property CurrentAddress: String read GetCurrentAddress;
property CurrentFileSourceIndex: Integer read GetCurrentFileSourceIndex;
@ -1536,7 +1536,7 @@ begin
Result := FWatchPath <> EmptyStr;
end;
procedure TFileView.SetFileFilter(const NewFilter: String; NewFilterOptions: TQuickSearchOptions);
procedure TFileView.SetFileFilter(NewFilter: String; NewFilterOptions: TQuickSearchOptions);
begin
// do not reload if filter has not changed
if (FFileFilter = NewFilter) and (FFilterOptions = NewFilterOptions) then

View file

@ -125,8 +125,8 @@ type
class procedure MakeDisplayFileList(aFileSource: IFileSource;
aFileSourceFiles: TFiles;
aFiles: TDisplayFiles;
aFileFilter: String;
aFilterOptions: TQuickSearchOptions);
const aFileFilter: String;
const aFilterOptions: TQuickSearchOptions);
end;
{ TFilePropertiesRetriever }
@ -410,7 +410,7 @@ begin
if Assigned(FTmpFileSourceFiles) then
begin
TFileSorter.Sort(FTmpFileSourceFiles, FSortings);
TFileSorter.Sort(FTmpFileSourceFiles, FSortings);
// Check if up-dir '..' is present.
// If it is present it will usually be the first file.
@ -475,8 +475,8 @@ class procedure TFileListBuilder.MakeDisplayFileList(
aFileSource: IFileSource;
aFileSourceFiles: TFiles;
aFiles: TDisplayFiles;
aFileFilter: String;
aFilterOptions: TQuickSearchOptions);
const aFileFilter: String;
const aFilterOptions: TQuickSearchOptions);
var
AFile: TDisplayFile;
i: Integer;