You've already forked lazarus-ccr
Bug 23898 - responding to Abort in OnChange handler
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2691 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -583,39 +583,38 @@ end;
|
|||||||
|
|
||||||
procedure TDTCalendarForm.CloseCalendarForm(const AndSetTheDate: Boolean);
|
procedure TDTCalendarForm.CloseCalendarForm(const AndSetTheDate: Boolean);
|
||||||
begin
|
begin
|
||||||
if not FClosing then begin
|
if not FClosing then
|
||||||
SetClosingCalendarForm;
|
try
|
||||||
|
SetClosingCalendarForm;
|
||||||
if Assigned(DTPicker) and DTPicker.IsVisible then begin
|
|
||||||
|
|
||||||
if AndSetTheDate then begin
|
|
||||||
Inc(DTPicker.FUserChanging);
|
|
||||||
try
|
|
||||||
if DTPicker.DateIsNull then begin
|
|
||||||
// we'll set the time to 0.0 (midnight):
|
|
||||||
DTPicker.SetDateTime(Int(Cal.DateTime));
|
|
||||||
end else if not EqualDateTime(Int(DTPicker.DateTime),
|
|
||||||
Int(Cal.DateTime)) then begin
|
|
||||||
// we'll change the date, but keep the time:
|
|
||||||
DTPicker.SetDateTime(ComposeDateTime(Cal.DateTime, DTPicker.DateTime));
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
Dec(DTPicker.FUserChanging);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if Screen.ActiveCustomForm = Self then
|
|
||||||
DTPicker.SetFocusIfPossible;
|
|
||||||
|
|
||||||
Visible := False;
|
Visible := False;
|
||||||
|
|
||||||
Close;
|
if Assigned(DTPicker) and DTPicker.IsVisible then begin
|
||||||
DTPicker.DoCloseUp;
|
|
||||||
|
|
||||||
end else
|
if AndSetTheDate then begin
|
||||||
Close;
|
Inc(DTPicker.FUserChanging);
|
||||||
|
try
|
||||||
|
if DTPicker.DateIsNull then begin
|
||||||
|
// we'll set the time to 0.0 (midnight):
|
||||||
|
DTPicker.SetDateTime(Int(Cal.DateTime));
|
||||||
|
end else if not EqualDateTime(Int(DTPicker.DateTime),
|
||||||
|
Int(Cal.DateTime)) then begin
|
||||||
|
// we'll change the date, but keep the time:
|
||||||
|
DTPicker.SetDateTime(ComposeDateTime(Cal.DateTime, DTPicker.DateTime));
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Dec(DTPicker.FUserChanging);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
if Screen.ActiveCustomForm = Self then
|
||||||
|
DTPicker.SetFocusIfPossible;
|
||||||
|
|
||||||
|
DTPicker.DoCloseUp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
finally
|
||||||
|
Release;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2343,11 +2342,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomZVDateTimePicker.UpdateDate;
|
procedure TCustomZVDateTimePicker.UpdateDate;
|
||||||
|
const
|
||||||
|
InRecursiveCall: Boolean = False;
|
||||||
|
|
||||||
var
|
var
|
||||||
W: Array[1..3] of Word;
|
W: Array[1..3] of Word;
|
||||||
WT: Array[TTimeTextPart] of Word;
|
WT: Array[TTimeTextPart] of Word;
|
||||||
YearPos, I: Integer;
|
YearPos, I: Integer;
|
||||||
TTP, TTPEnd: TTimeTextPart;
|
TTP, TTPEnd: TTimeTextPart;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FUserChangedText := False;
|
FUserChangedText := False;
|
||||||
|
|
||||||
@ -2359,6 +2362,24 @@ begin
|
|||||||
FDateTime := ComposeDateTime(FMinDate, FDateTime);
|
FDateTime := ComposeDateTime(FMinDate, FDateTime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if not InRecursiveCall then begin // we'll skip the next part in
|
||||||
|
// recursive calls which could be made through Change or UndoChanges
|
||||||
|
InRecursiveCall := True;
|
||||||
|
try
|
||||||
|
if FUserChanging > 0 then begin // this means that the change is caused by user interaction
|
||||||
|
try
|
||||||
|
Change;
|
||||||
|
except
|
||||||
|
UndoChanges;
|
||||||
|
raise;
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
FConfirmedDateTime := FDateTime;
|
||||||
|
finally
|
||||||
|
InRecursiveCall := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
if FKind in [dtkTime, dtkDateTime] then begin
|
if FKind in [dtkTime, dtkDateTime] then begin
|
||||||
if DateIsNull then begin
|
if DateIsNull then begin
|
||||||
FTimeText[ttpHour] := '99';
|
FTimeText[ttpHour] := '99';
|
||||||
@ -2460,11 +2481,6 @@ begin
|
|||||||
for I := Low(FTextPart) to High(FTextPart) do
|
for I := Low(FTextPart) to High(FTextPart) do
|
||||||
FTextPart[I] := '';
|
FTextPart[I] := '';
|
||||||
|
|
||||||
if FUserChanging > 0 then // this means that the change is caused by user interaction
|
|
||||||
Change
|
|
||||||
else
|
|
||||||
FConfirmedDateTime := FDateTime;
|
|
||||||
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user