mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #1659:
* fix exception on closing customize dialog * use empty string when converting clNone to and from web color, instead of #ffffff
This commit is contained in:
@ -395,6 +395,8 @@ type
|
|||||||
function DirSep: Char;
|
function DirSep: Char;
|
||||||
function StrHasNumChars(const AStr: String; NumChars: Cardinal): Boolean;
|
function StrHasNumChars(const AStr: String; NumChars: Cardinal): Boolean;
|
||||||
procedure FindComponentInstances(BaseForm: TComponent; ClassType: TClass; var List: TObjectList);
|
procedure FindComponentInstances(BaseForm: TComponent; ClassType: TClass; var List: TObjectList);
|
||||||
|
function WebColorStrToColorDef(WebColor: string; Default: TColor): TColor;
|
||||||
|
|
||||||
var
|
var
|
||||||
AppSettings: TAppSettings;
|
AppSettings: TAppSettings;
|
||||||
MutexHandle: THandle = 0;
|
MutexHandle: THandle = 0;
|
||||||
@ -3018,6 +3020,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function WebColorStrToColorDef(WebColor: string; Default: TColor): TColor;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
Result := WebColorStrToColor(WebColor);
|
||||||
|
except
|
||||||
|
Result := Default;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Threading stuff }
|
{ Threading stuff }
|
||||||
|
@ -63,11 +63,8 @@ procedure TfrmCustomizeHighlighter.Modified(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
// Apply modification to current attribute
|
// Apply modification to current attribute
|
||||||
// Silence exception caused by invalid color strings
|
// Silence exception caused by invalid color strings
|
||||||
try
|
FAttr.Background := WebColorStrToColorDef(editBackground.Text, clNone);
|
||||||
FAttr.Background := WebColorStrToColor(editBackground.Text);
|
FAttr.Foreground := WebColorStrToColorDef(editForeground.Text, clNone);
|
||||||
FAttr.Foreground := WebColorStrToColor(editForeground.Text);
|
|
||||||
except
|
|
||||||
end;
|
|
||||||
if chkBold.Checked then
|
if chkBold.Checked then
|
||||||
FAttr.Style := FAttr.Style + [fsBold]
|
FAttr.Style := FAttr.Style + [fsBold]
|
||||||
else
|
else
|
||||||
@ -111,10 +108,7 @@ begin
|
|||||||
Edit := Sender as TButtonedEdit;
|
Edit := Sender as TButtonedEdit;
|
||||||
Dialog := TColorDialog.Create(Self);
|
Dialog := TColorDialog.Create(Self);
|
||||||
Dialog.Options := [cdFullOpen, cdAnyColor];
|
Dialog.Options := [cdFullOpen, cdAnyColor];
|
||||||
try
|
Dialog.Color := WebColorStrToColorDef(Edit.Text, clNone);
|
||||||
Dialog.Color := WebColorStrToColor(Edit.Text);
|
|
||||||
except
|
|
||||||
end;
|
|
||||||
if Dialog.Execute then begin
|
if Dialog.Execute then begin
|
||||||
Edit.Text := ColorToWebColorStr(Dialog.Color);
|
Edit.Text := ColorToWebColorStr(Dialog.Color);
|
||||||
end;
|
end;
|
||||||
@ -142,8 +136,9 @@ begin
|
|||||||
// Form destroyed
|
// Form destroyed
|
||||||
if Assigned(FHighlighter) then
|
if Assigned(FHighlighter) then
|
||||||
FHighlighter.Free;
|
FHighlighter.Free;
|
||||||
if Assigned(FAttr) then
|
// causes an exception when closing:
|
||||||
FAttr.Free;
|
//if Assigned(FAttr) then
|
||||||
|
// FAttr.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmCustomizeHighlighter.listboxAttributesClick(Sender: TObject);
|
procedure TfrmCustomizeHighlighter.listboxAttributesClick(Sender: TObject);
|
||||||
@ -166,10 +161,18 @@ begin
|
|||||||
chkItalic.Enabled := AttrSelected;
|
chkItalic.Enabled := AttrSelected;
|
||||||
pnlSample.Enabled := AttrSelected;
|
pnlSample.Enabled := AttrSelected;
|
||||||
// Overtake values
|
// Overtake values
|
||||||
editBackground.Text := IfThen(AttrSelected, ColorToWebColorStr(FAttr.Background), '');
|
if AttrSelected then begin
|
||||||
editForeground.Text := IfThen(AttrSelected, ColorToWebColorStr(FAttr.Foreground), '');
|
editBackground.Text := IfThen(FAttr.Background <> clNone, ColorToWebColorStr(FAttr.Background), '');
|
||||||
chkBold.Checked := AttrSelected and (fsBold in FAttr.Style);
|
editForeground.Text := IfThen(FAttr.Foreground <> clNone, ColorToWebColorStr(FAttr.Foreground), '');
|
||||||
chkItalic.Checked := AttrSelected and (fsItalic in FAttr.Style);
|
chkBold.Checked := fsBold in FAttr.Style;
|
||||||
|
chkItalic.Checked := fsItalic in FAttr.Style;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
editBackground.Text := '';
|
||||||
|
editForeground.Text := '';
|
||||||
|
chkBold.Checked := False;
|
||||||
|
chkItalic.Checked := False;
|
||||||
|
end;
|
||||||
UpdateSampleBox;
|
UpdateSampleBox;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user