From 54a4101f8ae7568d73e21d752caba4a1676d7cef Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 19 May 2018 22:05:59 +0000 Subject: [PATCH] tvplanit: Fix crash of VpDayViewPainter caused by deleting uncreated regions (issue #33763, idea by linux-man) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6439 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../tvplanit/source/vpdayviewpainter.pas | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/components/tvplanit/source/vpdayviewpainter.pas b/components/tvplanit/source/vpdayviewpainter.pas index a1589db12..8b3d343e0 100644 --- a/components/tvplanit/source/vpdayviewpainter.pas +++ b/components/tvplanit/source/vpdayviewpainter.pas @@ -1070,9 +1070,9 @@ end; procedure TVpDayViewPainter.DrawEventText(const AText: String; const AEventRect, AIconRect: TRect; ALevel: Integer); var - WorkRegion1: HRGN; - WorkRegion2: HRGN; - TextRegion: HRGN; + WorkRegion1: HRGN = 0; + WorkRegion2: HRGN = 0; + TextRegion: HRGN = 0; CW: Integer; begin if (FDayView.WrapStyle <> wsNone) then begin @@ -1104,15 +1104,9 @@ begin Rect(AEventRect.Right - 6, AEventRect.Bottom - 7, AEventRect.Right - 3, AEventRect.Bottom - 4)); end; finally - if ((AEventRect.Bottom > AIconRect.Bottom) and (AEventRect.Left > AIconRect.Right)) or - (FDayView.WrapStyle = wsIconFlow) - then begin - DeleteObject(WorkRegion1); - DeleteObject(WorkRegion2); - DeleteObject(TextRegion); - end else begin - DeleteObject(TextRegion); - end; + if WorkRegion1 <> 0 then DeleteObject(WorkRegion1); + if WorkRegion2 <> 0 then DeleteObject(WorkRegion2); + if TextRegion <> 0 then DeleteObject(TextRegion); end; end else begin