From f67165ae31509fa20275b3d3763874ad03b1234d Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 4 Jul 2024 22:40:42 +0200 Subject: [PATCH] * empty Rect does not extend the rect in UnionRect, based on patch provided by Werner Pamler, resolves #40680 --- rtl/objpas/types.pp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/rtl/objpas/types.pp b/rtl/objpas/types.pp index f6790e6071..45052701df 100644 --- a/rtl/objpas/types.pp +++ b/rtl/objpas/types.pp @@ -875,19 +875,26 @@ function UnionRect(var Rect : TRect;const R1,R2 : TRect) : Boolean; var lRect: TRect; begin - lRect:=R1; - if R2.LeftR1.Right then - lRect.Right:=R2.Right; - if R2.Bottom>R1.Bottom then - lRect.Bottom:=R2.Bottom; + if IsRectEmpty(R1) then + lRect:=R2 + else if IsRectEmpty(R2) then + lRect:=R1 + else + begin + lRect:=R1; + if R2.LeftR1.Right then + lRect.Right:=R2.Right; + if R2.Bottom>R1.Bottom then + lRect.Bottom:=R2.Bottom; + end; Result:=not IsRectEmpty(lRect); if Result then - Rect := lRect + Rect:=lRect else FillChar(Rect,SizeOf(Rect),0); end;