From 43948ba297e4d07f0a10102909c40f53809f6e01 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 10 Jun 2016 01:39:39 +0000 Subject: [PATCH] tvplanit: Fix crash in WeekView caused by destruction of inplace editor. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4705 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpweekview.pas | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index 7be58ad8f..cf2c7d015 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -483,6 +483,7 @@ end; destructor TVpWeekView.Destroy; begin + FreeAndNil(wvInplaceEditor); FDayHeadAttributes.Free; FAllDayEventAttr.Free; FHeadAttr.Free; @@ -1822,13 +1823,16 @@ begin if AllowIt then begin { create and spawn the in-place editor } - wvInPlaceEditor := TVpWvInPlaceEdit.Create(Self); - wvInPlaceEditor.Parent := self; - wvInPlaceEditor.OnExit := EndEdit; + if wvInplaceEditor = nil then begin + wvInPlaceEditor := TVpWvInPlaceEdit.Create(Self); + wvInPlaceEditor.Parent := self; + wvInPlaceEditor.OnExit := EndEdit; + end; wvInPlaceEditor.SetBounds(wvActiveEventRec.Left + TextMargin, wvActiveEventRec.Top, wvActiveEventRec.Right - (TextMargin*2), wvActiveEventRec.Bottom- (TextMargin*2)); + wvInplaceEditor.Show; wvInPlaceEditor.Text := ActiveEvent.Description; Invalidate; wvInPlaceEditor.SetFocus; @@ -1932,7 +1936,7 @@ end; procedure TVpWeekView.EndEdit(Sender: TObject); begin - if wvInPlaceEditor <> nil then begin + if (wvInPlaceEditor <> nil) and (ActiveEvent <> nil) then begin if wvInPlaceEditor.Text <> ActiveEvent.Description then begin ActiveEvent.Description := wvInPlaceEditor.Text; ActiveEvent.Changed := true; @@ -1940,7 +1944,7 @@ begin FAfterEdit(self, ActiveEvent); DataStore.PostEvents; end; - FreeAndNil(wvInPlaceEditor); + wvInplaceEditor.Hide; Invalidate; // SetFocus; end;