From 4b679593c806e2255b60a42ab7fbf241bc98654e Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 5 Nov 2014 12:20:06 +0000 Subject: [PATCH] lcl: TCustomImage.Paint: do not invalidate when initializing the image during paint git-svn-id: trunk@46758 - --- lcl/extctrls.pp | 2 ++ lcl/include/customimage.inc | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index ea3f5f3d8e..5323a03f7f 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -480,6 +480,7 @@ type FTransparent: Boolean; FStretch: Boolean; FUseAncestorCanvas: boolean; + FPainting: boolean; function GetCanvas: TCanvas; procedure SetAntialiasingMode(AValue: TAntialiasingMode); procedure SetPicture(const AValue: TPicture); @@ -500,6 +501,7 @@ type destructor Destroy; override; property Canvas: TCanvas read GetCanvas; function DestRect: TRect; virtual; + procedure Invalidate; override; public property AntialiasingMode: TAntialiasingMode read FAntialiasingMode write SetAntialiasingMode default amDontCare; property Align; diff --git a/lcl/include/customimage.inc b/lcl/include/customimage.inc index 241f340885..ff70427e31 100644 --- a/lcl/include/customimage.inc +++ b/lcl/include/customimage.inc @@ -163,6 +163,12 @@ begin OffsetRect(Result,(ImgWidth-PicWidth) div 2,(ImgHeight-PicHeight) div 2); end; +procedure TCustomImage.Invalidate; +begin + if FPainting then exit; + inherited Invalidate; +end; + procedure TCustomImage.CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); begin @@ -208,7 +214,12 @@ begin C := inherited Canvas; R := DestRect; C.AntialiasingMode := FAntialiasingMode; - C.StretchDraw(R, Picture.Graphic); + FPainting:=true; + try + C.StretchDraw(R, Picture.Graphic); + finally + FPainting:=false; + end; FUseAncestorCanvas := True; try