mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Non-integer input using audioinfo Search plugin causes error/crash (fixes #922)
This commit is contained in:
parent
d4742bcb40
commit
5777435901
2 changed files with 93 additions and 50 deletions
107
src/fFindDlg.pas
107
src/fFindDlg.pas
|
|
@ -1771,8 +1771,10 @@ begin
|
|||
actNewSearchClearFilters.Enabled := False;
|
||||
actLastSearch.Enabled := False;
|
||||
|
||||
if (not frmContentPlugins.chkUsePlugins.Checked) OR (not gSearchWithWDXPluginInProgress) then
|
||||
begin
|
||||
try
|
||||
if (frmContentPlugins.chkUsePlugins.Checked) and (gSearchWithWDXPluginInProgress) then
|
||||
raise EConvertError.Create(rsSearchWithWDXPluginInProgress);
|
||||
|
||||
FillFindOptions(SearchTemplate, True);
|
||||
if frmContentPlugins.chkUsePlugins.Checked then
|
||||
begin
|
||||
|
|
@ -1789,67 +1791,66 @@ begin
|
|||
|
||||
FoundedStringCopy.OnChange:= @FoundedStringCopyAdded;
|
||||
|
||||
try
|
||||
if (cbUsePlugin.Checked) and (cmbPlugin.ItemIndex <> -1) then
|
||||
if (cbUsePlugin.Checked) and (cmbPlugin.ItemIndex <> -1) then
|
||||
begin
|
||||
if not gSearchWithDSXPluginInProgress then
|
||||
begin
|
||||
if not gSearchWithDSXPluginInProgress then
|
||||
gSearchWithDSXPluginInProgress := True;
|
||||
FSearchWithDSXPluginInProgress := True;
|
||||
frmFindDlgUsingPluginDSX := Self;
|
||||
if DSXPlugins.LoadModule(cmbPlugin.ItemIndex) then
|
||||
begin
|
||||
gSearchWithDSXPluginInProgress := True;
|
||||
FSearchWithDSXPluginInProgress := True;
|
||||
frmFindDlgUsingPluginDSX := Self;
|
||||
if DSXPlugins.LoadModule(cmbPlugin.ItemIndex) then
|
||||
begin
|
||||
FindOptionsToDSXSearchRec(SearchTemplate, sr);
|
||||
DSXPlugins.GetDSXModule(cmbPlugin.ItemIndex).CallInit(@SAddFileProc, @SUpdateStatusProc);
|
||||
DSXPlugins.GetDSXModule(cmbPlugin.ItemIndex).CallStartSearch(sr);
|
||||
end
|
||||
else
|
||||
StopSearch;
|
||||
FindOptionsToDSXSearchRec(SearchTemplate, sr);
|
||||
DSXPlugins.GetDSXModule(cmbPlugin.ItemIndex).CallInit(@SAddFileProc, @SUpdateStatusProc);
|
||||
DSXPlugins.GetDSXModule(cmbPlugin.ItemIndex).CallStartSearch(sr);
|
||||
end
|
||||
else
|
||||
begin
|
||||
MsgError(rsSearchWithDSXPluginInProgress);
|
||||
StopSearch;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if cbSelectedFiles.Checked then PassedSelectedFiles := FSelectedFiles;
|
||||
|
||||
if cbOpenedTabs.Checked then
|
||||
begin
|
||||
frmMain.GetListOpenedPaths(FSelectedFiles);
|
||||
PassedSelectedFiles := FSelectedFiles;
|
||||
end;
|
||||
|
||||
FFindThread := TFindThread.Create(SearchTemplate, PassedSelectedFiles);
|
||||
with FFindThread do
|
||||
begin
|
||||
Archive := FWcxModule;
|
||||
Items := FoundedStringCopy;
|
||||
OnTerminate := @ThreadTerminate; // will update the buttons after search is finished
|
||||
end;
|
||||
|
||||
SetWindowCaption(wcs_StartSearch);
|
||||
|
||||
FTimeSearch := '';
|
||||
FFindThread.Start;
|
||||
FUpdateTimer.Enabled := True;
|
||||
FUpdateTimer.OnTimer(FUpdateTimer);
|
||||
|
||||
FRButtonPanelSender := nil;
|
||||
MsgError(rsSearchWithDSXPluginInProgress);
|
||||
StopSearch;
|
||||
end;
|
||||
except
|
||||
StopSearch;
|
||||
raise;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if cbSelectedFiles.Checked then PassedSelectedFiles := FSelectedFiles;
|
||||
|
||||
if cbOpenedTabs.Checked then
|
||||
begin
|
||||
frmMain.GetListOpenedPaths(FSelectedFiles);
|
||||
PassedSelectedFiles := FSelectedFiles;
|
||||
end;
|
||||
|
||||
FFindThread := TFindThread.Create(SearchTemplate, PassedSelectedFiles);
|
||||
with FFindThread do
|
||||
begin
|
||||
Archive := FWcxModule;
|
||||
Items := FoundedStringCopy;
|
||||
OnTerminate := @ThreadTerminate; // will update the buttons after search is finished
|
||||
end;
|
||||
|
||||
SetWindowCaption(wcs_StartSearch);
|
||||
|
||||
FTimeSearch := '';
|
||||
FFindThread.Start;
|
||||
FUpdateTimer.Enabled := True;
|
||||
FUpdateTimer.OnTimer(FUpdateTimer);
|
||||
|
||||
FRButtonPanelSender := nil;
|
||||
end;
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
if (E is EConvertError) then
|
||||
msgError(E.Message)
|
||||
else
|
||||
raise;
|
||||
StopSearch;
|
||||
AfterSearchStopped;
|
||||
AfterSearchFocus;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
MsgError(rsSearchWithWDXPluginInProgress);
|
||||
StopSearch;
|
||||
AfterSearchStopped;
|
||||
AfterSearchFocus;
|
||||
end;
|
||||
end; //cm_Start
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
Content plugin search control
|
||||
|
||||
Copyright (C) 2014-2019 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2014-2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -26,7 +26,7 @@ unit uSearchContent;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Controls, StdCtrls, ExtCtrls, uFindFiles;
|
||||
Classes, SysUtils, Controls, StdCtrls, ExtCtrls, LCLType, uFindFiles;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -54,6 +54,8 @@ type
|
|||
procedure SetUnitName(AValue: String);
|
||||
procedure SetValue(AValue: Variant);
|
||||
procedure SetComboBox(ComboBox: TComboBox; const Value, Error: String);
|
||||
procedure ComboValueKeyPress(Sender: TObject; var Key: Char);
|
||||
procedure ComboValueUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
|
@ -144,6 +146,7 @@ begin
|
|||
FComboUnit.Items.Clear;
|
||||
FComboValue.Items.Clear;
|
||||
FComboOperator.Items.Clear;
|
||||
FComboValue.Text:= EmptyStr;
|
||||
if (FComboField.ItemIndex < 0) then Exit;
|
||||
|
||||
WdxField:= TWdxField(FComboField.Items.Objects[FComboField.ItemIndex]);
|
||||
|
|
@ -302,6 +305,43 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TPluginPanel.ComboValueKeyPress(Sender: TObject; var Key: Char);
|
||||
var
|
||||
WdxField: TWdxField;
|
||||
begin
|
||||
if (FComboField.ItemIndex < 0) then Exit;
|
||||
WdxField:= TWdxField(FComboField.Items.Objects[FComboField.ItemIndex]);
|
||||
case WdxField.FType of
|
||||
FT_NUMERIC_32,
|
||||
FT_NUMERIC_64:
|
||||
begin
|
||||
if not (Key in ['0'..'9', Chr(VK_BACK)]) then
|
||||
Key:= #0;
|
||||
end;
|
||||
FT_NUMERIC_FLOATING:
|
||||
begin
|
||||
if not (Key in ['0'..'9', Chr(VK_BACK), DefaultFormatSettings.DecimalSeparator]) then
|
||||
Key:= #0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPluginPanel.ComboValueUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||
var
|
||||
WdxField: TWdxField;
|
||||
begin
|
||||
if (FComboField.ItemIndex < 0) then Exit;
|
||||
WdxField:= TWdxField(FComboField.Items.Objects[FComboField.ItemIndex]);
|
||||
case WdxField.FType of
|
||||
FT_NUMERIC_32,
|
||||
FT_NUMERIC_64,
|
||||
FT_NUMERIC_FLOATING:
|
||||
begin
|
||||
if (Length(UTF8Key) > 1) then UTF8Key:= #0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TPluginPanel.Create(TheOwner: TComponent);
|
||||
var
|
||||
I: Integer;
|
||||
|
|
@ -328,6 +368,8 @@ begin
|
|||
FComboOperator.Style:= csDropDownList;
|
||||
|
||||
FComboValue:= TComboBox.Create(Self);
|
||||
FComboValue.OnKeyPress:= @ComboValueKeyPress;
|
||||
FComboValue.OnUTF8KeyPress:= @ComboValueUTF8KeyPress;
|
||||
FComboValue.Parent:= Self;
|
||||
|
||||
FComboUnit:= TComboBox.Create(Self);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue