From e45bb283dfa03c54cb8408d552fe5c42124ddede Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 2 Sep 2016 14:35:14 +0000 Subject: [PATCH] tvplanit: Fix Lazarus crashing if datastore is deleted from a form containing a MonthView. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5120 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpmonthviewpainter.pas | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/tvplanit/source/vpmonthviewpainter.pas b/components/tvplanit/source/vpmonthviewpainter.pas index 30c21ff19..5e5a506a3 100644 --- a/components/tvplanit/source/vpmonthviewpainter.pas +++ b/components/tvplanit/source/vpmonthviewpainter.pas @@ -376,13 +376,15 @@ begin end; RenderCanvas.Font.Color := RealSelDayColor; RenderCanvas.Font.Style := FMonthView.DayNumberFont.Style + [fsBold]; - if (FMonthView.EventDayStyle <> []) and (FMonthView.DataStore.Resource <> nil) and + if (FMonthView.EventDayStyle <> []) and (FMonthView.Datastore <> nil) and + (FMonthView.DataStore.Resource <> nil) and (FMonthView.DataStore.Resource.Schedule.EventCountByDay(ThisDate) > 0) then RenderCanvas.Font.Style := RenderCanvas.Font.Style + FMonthView.EventDayStyle; end else begin { Set the font style for days which have events. } - if (FMonthView.EventDayStyle <> []) and (FMonthView.DataStore.Resource <> nil) and + if (FMonthView.EventDayStyle <> []) and (FMonthview.Datastore <> nil) and + (FMonthView.DataStore.Resource <> nil) and (FMonthView.DataStore.Resource.Schedule.EventCountByDay(ThisDate) > 0) then RenderCanvas.Font.Style := RenderCanvas.Font.Style + FMonthView.EventDayStyle @@ -484,13 +486,15 @@ begin DrawFocusRect(TextRect); RenderCanvas.Font.Color := RealSelDayColor; RenderCanvas.Font.Style := FMonthView.DayNumberFont.Style + [fsBold]; - if (FMonthView.EventDayStyle <> []) and (FMonthView.DataStore.Resource <> nil) and + if (FMonthView.EventDayStyle <> []) and (FMonthview.Datastore <> nil) and + (FMonthView.DataStore.Resource <> nil) and (FMonthView.DataStore.Resource.Schedule.EventCountByDay(ThisDate) > 0) then RenderCanvas.Font.Style := RenderCanvas.Font.Style + FMonthView.EventDayStyle; end else begin { Set the font style for days which have events. } - if (FMonthView.EventDayStyle <> []) and (FMonthView.DataStore.Resource <> nil) and + if (FMonthView.EventDayStyle <> []) and (FMonthView.Datastore <> nil) and + (FMonthView.DataStore.Resource <> nil) and (FMonthView.DataStore.Resource.Schedule.EventCountByDay(ThisDate) > 0) then RenderCanvas.Font.Style := RenderCanvas.Font.Style + FMonthView.EventDayStyle