MaskEdit: if an exception is raised inside SetEditMask, make the control UnMasked (otherwise havoc will occur).

git-svn-id: trunk@64904 -
This commit is contained in:
bart 2021-04-02 21:52:01 +00:00
parent 9124789bc5
commit c3c7456d6f

View File

@ -647,6 +647,13 @@ Var
Include(CharSet, C); Include(CharSet, C);
end; end;
procedure UndoMask;
begin
ClearInternalMask(FMask, FMaskLength);
MaxLength := 0;
Clear;
end;
begin begin
//Setting Mask while loading has unexpected and unwanted side-effects //Setting Mask while loading has unexpected and unwanted side-effects
if (csLoading in ComponentState) then if (csLoading in ComponentState) then
@ -691,7 +698,10 @@ begin
if InSet then if InSet then
begin //InSet begin //InSet
if (Length(CP) <> 1) then if (Length(CP) <> 1) then
begin
UndoMask;
raise EInvalidEditMask.Create(SIllegalCharInSet); raise EInvalidEditMask.Create(SIllegalCharInSet);
end;
case CP[1] of case CP[1] of
cMask_SetNegate: cMask_SetNegate:
begin begin
@ -713,7 +723,10 @@ begin
begin begin
//debugln('Set closed:'); //debugln('Set closed:');
if (CharSet = []) then if (CharSet = []) then
begin
UndoMask;
raise EInvalidEditMask.Create(SEmptySet); raise EInvalidEditMask.Create(SEmptySet);
end;
//debugln(['IsNegative=',IsNegative]); //debugln(['IsNegative=',IsNegative]);
if IsNegative then if IsNegative then
begin begin
@ -742,7 +755,10 @@ begin
cMask_SetRange: cMask_SetRange:
begin begin
if InRange then if InRange then
begin
UndoMask;
raise EInvalidEditMask.Create(SIllegalRangeChar); raise EInvalidEditMask.Create(SIllegalRangeChar);
end;
if (CharSet = []) then if (CharSet = []) then
begin begin
//debugln('Adding - to emty set'); //debugln('Adding - to emty set');
@ -928,7 +944,10 @@ begin
end; end;
end; end;
if InSet then if InSet then
begin
UndoMask;
raise EInvalidEditMask.Create(SUnclosedSet); raise EInvalidEditMask.Create(SUnclosedSet);
end;
//debugln('TCustomMaskEdit.SetEditMask: Internal Mask:'); //debugln('TCustomMaskEdit.SetEditMask: Internal Mask:');
//debugln(DbgS(FMask)); //debugln(DbgS(FMask));