tvplanit: Fix crash of TaskList due to inplace editor being destroyed.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4709 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-10 19:59:00 +00:00
parent b703a9f89e
commit fc0be1bb18

View File

@ -908,7 +908,7 @@ var
if (LineRect.Top + Trunc(RowHeight * 0.5) <= RealBottom) then begin if (LineRect.Top + Trunc(RowHeight * 0.5) <= RealBottom) then begin
{ if this is the selected task and we are not in edit mode, } { if this is the selected task and we are not in edit mode, }
{ then set background selection } { then set background selection }
if (Task = FActiveTask) and (tlInPlaceEditor = nil) if (Task = FActiveTask) and ((tlInPlaceEditor = nil) or not tlInplaceEditor.Visible)
and (not DisplayOnly) and Focused then begin and (not DisplayOnly) and Focused then begin
RenderCanvas.Brush.Color := BackgroundSelHighlight; RenderCanvas.Brush.Color := BackgroundSelHighlight;
RenderCanvas.FillRect(LineRect); RenderCanvas.FillRect(LineRect);
@ -934,7 +934,7 @@ var
end; end;
{ if this is the selected task, set highlight text color } { if this is the selected task, set highlight text color }
if (Task = FActiveTask) and (tlInPlaceEditor = nil) if (Task = FActiveTask) and ((tlInPlaceEditor = nil) or not tlInplaceEditor.Visible)
and (not DisplayOnly) and Focused then and (not DisplayOnly) and Focused then
RenderCanvas.Font.Color := ForegroundSelHighlight; RenderCanvas.Font.Color := ForegroundSelHighlight;
@ -1217,7 +1217,7 @@ end;
procedure TVpTaskList.SetTaskIndex(Value: Integer); procedure TVpTaskList.SetTaskIndex(Value: Integer);
begin begin
if (tlInPlaceEditor <> nil) then if (tlInPlaceEditor <> nil) and tlInplaceEditor.Visible then
EndEdit(self); EndEdit(self);
if (Value < DataStore.Resource.Tasks.Count) if (Value < DataStore.Resource.Tasks.Count)
@ -1522,10 +1522,13 @@ begin
R.Top := R.Top + TextMargin; R.Top := R.Top + TextMargin;
R.Left := R.Left + TextMargin - 1; R.Left := R.Left + TextMargin - 1;
{ create and spawn the in-place editor } { create and spawn the in-place editor }
tlInPlaceEditor := TVpTLInPlaceEdit.Create(Self); if tlInplaceEditor = nil then begin
tlInPlaceEditor.Parent := self; tlInPlaceEditor := TVpTLInPlaceEdit.Create(Self);
tlInPlaceEditor.OnExit := EndEdit; tlInPlaceEditor.Parent := self;
tlInPlaceEditor.Move(R , true); tlInPlaceEditor.OnExit := EndEdit;
end;
tlInplaceEditor.Show;
tlInPlaceEditor.Move(R, true);
tlInPlaceEditor.Text := FActiveTask.Description; tlInPlaceEditor.Text := FActiveTask.Description;
tlInPlaceEditor.Font.Assign(Font); tlInPlaceEditor.Font.Assign(Font);
tlInPlaceEditor.SelectAll; tlInPlaceEditor.SelectAll;
@ -1536,7 +1539,7 @@ end;
procedure TVpTaskList.EndEdit(Sender: TObject); procedure TVpTaskList.EndEdit(Sender: TObject);
begin begin
if tlInPlaceEditor <> nil then begin if (tlInPlaceEditor <> nil) and tlInplaceEditor.Visible then begin
if tlInPlaceEditor.Text <> FActiveTask.Description then begin if tlInPlaceEditor.Text <> FActiveTask.Description then begin
FActiveTask.Description := tlInPlaceEditor.Text; FActiveTask.Description := tlInPlaceEditor.Text;
FActiveTask.Changed := true; FActiveTask.Changed := true;
@ -1545,9 +1548,7 @@ begin
if Assigned(FAfterEdit) then if Assigned(FAfterEdit) then
FAfterEdit(self, FActiveTask); FAfterEdit(self, FActiveTask);
end; end;
tlInPlaceEditor.Hide;
tlInPlaceEditor.Free;
tlInPlaceEditor := nil;
SetFocus; SetFocus;
Invalidate; Invalidate;
end; end;
@ -1631,7 +1632,7 @@ procedure TVpTaskList.WMVScroll(var Msg: TLMVScroll);
begin begin
{ for simplicity, bail out of editing while scrolling. } { for simplicity, bail out of editing while scrolling. }
EndEdit(Self); EndEdit(Self);
if tlInPlaceEditor <> nil then Exit; if (tlInPlaceEditor <> nil) and tlInplaceEditor.Visible then Exit;
case Msg.ScrollCode of case Msg.ScrollCode of
SB_LINEUP : SB_LINEUP :