Skip to content

Commit 79bcd1d

Browse files
committed
fix: remove dead code, fix some compiler hints
1 parent 8d119a0 commit 79bcd1d

File tree

4 files changed

+5
-54
lines changed

4 files changed

+5
-54
lines changed

source/apphelpers.pas

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,6 @@ TAppSettings = class(TObject)
415415
function GetExecutableBits: Byte;
416416
procedure Help(Sender: TObject; Anchor: String);
417417
function PortOpen(Port: Word): Boolean;
418-
function IsValidFilePath(FilePath: String): Boolean;
419-
//function FileIsWritable(FilePath: String): Boolean;
420418
//function GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion: DWORD; out pdwReturnedProductType: DWORD): BOOL stdcall; external kernel32 delayed;
421419
//function GetCurrentPackageFullName(out Len: Cardinal; Name: PWideChar): Integer; stdcall; external kernel32 delayed;
422420
function GetThemeColor(Color: TColor): TColor;
@@ -1479,7 +1477,7 @@ procedure FixVT(VT: TVirtualStringTree; MultiLineCount: Word=1);
14791477
VT.TextMargin := 6;
14801478
VT.Margin := 2;
14811479
// Disable hottracking in non-Vista mode, looks ugly in XP, but nice in Vista
1482-
if (toUseExplorerTheme in VT.TreeOptions.PaintOptions) {$IfDef WINDOWS} and true {$EndIf} then
1480+
if (toUseExplorerTheme in VT.TreeOptions.PaintOptions) then
14831481
VT.TreeOptions.PaintOptions := VT.TreeOptions.PaintOptions + [toHotTrack]
14841482
else
14851483
VT.TreeOptions.PaintOptions := VT.TreeOptions.PaintOptions - [toHotTrack];
@@ -2871,39 +2869,6 @@ function PortOpen(Port: Word): Boolean;
28712869
{$EndIf}
28722870
end;
28732871

2874-
function IsValidFilePath(FilePath: String): Boolean;
2875-
var
2876-
Pieces: TStringList;
2877-
i: Integer;
2878-
begin
2879-
// Check file path for invalid characters. See http://www.heidisql.com/forum.php?t=20873
2880-
Result := True;
2881-
Pieces := TStringList.Create;
2882-
SplitRegExpr('[\\\/]', FilePath, Pieces);
2883-
// Todo: implement cross platformic
2884-
{for i:=1 to Pieces.Count-1 do begin
2885-
Result := Result and TPath.HasValidFileNameChars(Pieces[i], False);
2886-
end;}
2887-
Pieces.Free;
2888-
end;
2889-
2890-
2891-
{function FileIsWritable(FilePath: String): Boolean;
2892-
var
2893-
hFile: DWORD;
2894-
begin
2895-
// Check if file is writable
2896-
// replaced through LazFileUtils.FileIsWritable
2897-
if not FileExists(FilePath) then begin
2898-
// Return true if file does not exist
2899-
Result := True;
2900-
end else begin
2901-
hFile := CreateFile(PChar(FilePath), GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0);
2902-
Result := hFile <> INVALID_HANDLE_VALUE;
2903-
CloseHandle(hFile);
2904-
end;
2905-
end;}
2906-
29072872

29082873
function GetThemeColor(Color: TColor): TColor;
29092874
begin
@@ -3155,7 +3120,7 @@ function GetApplicationName: String;
31553120

31563121
procedure CopyImageList(SourceList, TargetList: TImageList);
31573122
var
3158-
i, j, ResIdx, ResWidth: Integer;
3123+
i, ResIdx, ResWidth: Integer;
31593124
TempBitmap: TBitmap;
31603125
TempBitmapList: Array of TRasterImage;
31613126
const

source/grideditlinks.pas

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface
1010
Forms, Graphics, Messages, laz.VirtualTrees, ComCtrls, SysUtils, Classes,
1111
StdCtrls, ExtCtrls, CheckLst, Controls, Types, Dialogs, Menus, MaskEdit, DateUtils, Math,
1212
dbconnection, dbstructures, apphelpers, texteditor, bineditor, lazaruscompat,
13-
StrUtils, System.UITypes, RegExpr, extra_controls, EditBtn, LCLType, LCLIntf;
13+
System.UITypes, RegExpr, extra_controls, EditBtn, LCLType, LCLIntf;
1414

1515
type
1616
// Radio buttons and checkboxes which do not pass <Enter> key to their parent control
@@ -919,6 +919,8 @@ function TDateTimeEditorLink.MicroSecondsPrecision: Integer;
919919
Result := Length(msStr);
920920
end;
921921

922+
else
923+
Result := 0;
922924
end;
923925
end;
924926

source/main.pas

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,27 +2304,13 @@ procedure TMainForm.AfterFormCreate;
23042304

23052305
function TMainForm.InitTabsIniFile: TIniFile;
23062306
var
2307-
//WaitingSince: UInt64;
2308-
//Attempts: Integer;
23092307
TabsIniFilename: String;
23102308
begin
23112309
// Try to open tabs.ini for writing or reading
2312-
// Taking multiple application instances into account
23132310
if AppSettings.PortableMode then
23142311
TabsIniFilename := GetAppDir + 'tabs.ini'
23152312
else
23162313
TabsIniFilename := AppSettings.DirnameUserAppData + 'tabs.ini';
2317-
{WaitingSince := GetTickCount64;
2318-
Attempts := 0;
2319-
while not FileIsWritable(TabsIniFilename) do begin
2320-
if GetTickCount64 - WaitingSince > 3000 then
2321-
Raise Exception.Create(f_('Could not open file %s', [TabsIniFilename]));
2322-
Sleep(200);
2323-
Inc(Attempts);
2324-
end;
2325-
if Attempts > 0 then begin
2326-
LogSQL(Format('Had to wait %d ms before opening %s', [GetTickCount64 - WaitingSince, TabsIniFilename]), lcDebug);
2327-
end;}
23282314
// Catch errors when file cannot be created
23292315
if not FileExists(TabsIniFilename) then begin
23302316
SaveUnicodeFile(TabsIniFilename, '', UTF8NoBOMEncoding);

source/tabletools.pas

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,8 +1841,6 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
18411841
FExportFileName := TargetFileName;
18421842
if comboExportOutputType.Text = OUTPUT_FILE_COMPRESSED then
18431843
TargetFileName := ChangeFileExt(TargetFileName, '_temp.sql');
1844-
if not IsValidFilePath(TargetFileName) then
1845-
raise EFCreateError.CreateFmt(_('Filename or path contains illegal characters: "%s"'), [TargetFilename]);
18461844
if not DirectoryExists(ExtractFilePath(FExportFileName)) then
18471845
ForceDirectories(ExtractFilePath(FExportFileName));
18481846
ExportStream := TFileStream.Create(TargetFileName, fmCreate or fmOpenWrite);

0 commit comments

Comments
 (0)