View Issue Details

IDProjectCategoryView StatusLast Update
0026004LazarusWidgetsetpublic2014-09-20 09:43
ReporterVojtech Cihak Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformamd64OSLinux 
Product Version1.3 (SVN) 
Summary0026004: CopyRect+InvalidateRect issue [Qt]
DescriptionCopyRect copies whole canvas to invalidated area while it should copy only part.

Demo has component with canvas (TCustomControl) and a red-yellow bitmap. Both Invalidate and InvalidateRect do the same. They copy top-left quarter of the bitmap to the component's canvas but result is different. InvalidateRect copies all - it's a bug.
Steps To ReproduceRun demo.

Click Invalidate and InvalidateRect button. It should produce the same visual output (as it does in GTK2). InvalidateRect button in Qt works wrongly, yellow part should be never visible.

Interesting is that it works well when invalidated rectangle begins at point [0,0]. You can try by uncommenting the line in demo source.
Additional InformationLazarus 1.3 r44668M FPC 2.7.1 x86_64-linux-qt
TagsNo tags attached.
Fixed in Revision44693,45066
LazTarget1.2.4
WidgetsetQT
Attached Files

Relationships

related to 0026342 closedZeljan Rikalo Qt does not respect ClipRect and PaintBox bounds 
related to 0026745 closedZeljan Rikalo [Qt] CopyRect - regression of 26004 
related to 0026744 closedZeljan Rikalo [Qt] CopyRect - regression of 26004 

Activities

Vojtech Cihak

2014-04-10 22:36

reporter  

CopyRect.zip (7,428 bytes)

Zeljan Rikalo

2014-04-11 08:36

developer  

patch26004_1.diff (1,006 bytes)   
Index: lcl/interfaces/qt/qtwinapi.inc
===================================================================
--- lcl/interfaces/qt/qtwinapi.inc	(revision 44672)
+++ lcl/interfaces/qt/qtwinapi.inc	(working copy)
@@ -6462,6 +6462,7 @@
   dx, dy: integer;
   OldRop: Integer;
   OldBkColor: TColorRef;
+  RestoreClip: Boolean;
 begin
   {$ifdef VerboseQtWinAPI}
     WriteLn('[WinAPI StretchMaskBlt]',
@@ -6601,7 +6602,16 @@
       if Rop <> SRCCOPY then
         DstQDC.Rop2 := Integer(Rop);
       try
+        RestoreClip := False;
+        if (SrcRect.Left < DstRect.Left) or (SrcRect.Top < DstRect.Top) and
+          DstQDC.getClipping and DstQDC.getClipRegion.containsRect(SrcRect) then
+        begin
+          RestoreClip := True;
+          DstQDC.setClipping(False);
+        end;
         DstQDC.drawImage(@DstRect, Image, @SrcRect, QMask, @MaskRect);
+        if RestoreClip then
+          DstQDC.setClipping(True);
       finally
         if Rop <> SRCCOPY then
           DstQDC.Rop2 := OldRop;
patch26004_1.diff (1,006 bytes)   

Zeljan Rikalo

2014-04-11 08:37

developer   ~0074293

Possible patch is attached. Such change need heavy testing.
IMO, this looks like another Qt clipping bug.

Vojtech Cihak

2014-04-11 11:31

reporter   ~0074297

I tested the patch with demo and with my project which heavily uses InvalidateRect + CopyRect.
All works well.

Zeljan Rikalo

2014-04-12 08:28

developer   ~0074335

Please test and close if ok.

Vojtech Cihak

2014-04-12 10:30

reporter   ~0074339

I tested with 44695.
Thanks.

Zeljan Rikalo

2014-05-17 23:10

developer   ~0075050

Unsetting clipping is not good idea in all cases.

Zeljan Rikalo

2014-05-17 23:12

developer   ~0075051

Vojtech, pls test with r45064 and close if ok.
I've found that unsetting clipping is not good because then eg. we have strange visual effects in VirtualStringTree.Now, in case when rects are equal it does not unset clipping, but just offsets SrcRect and that looks good to me.

Zeljan Rikalo

2014-05-17 23:32

developer   ~0075052

Forget r45064, something is wrong with it ... I'm to sleepy to fix it now .... so tomorrow.

Zeljan Rikalo

2014-05-18 09:20

developer   ~0075056

Finally it's fixed. Please test and close if ok. Your example works fine (it worked before too), but I've found that if an DstRect position is eg. lower than clipRegion then we have unwanted effect: image is drawn unclipped ,so covers things which should not be covered. This patch fixes such problem.

Vojtech Cihak

2014-05-18 13:16

reporter   ~0075066

I tested with r.45071. Thanks.

Issue History

Date Modified Username Field Change
2014-04-10 22:36 Vojtech Cihak New Issue
2014-04-10 22:36 Vojtech Cihak File Added: CopyRect.zip
2014-04-11 07:18 Zeljan Rikalo Assigned To => Zeljan Rikalo
2014-04-11 07:18 Zeljan Rikalo Status new => assigned
2014-04-11 08:36 Zeljan Rikalo File Added: patch26004_1.diff
2014-04-11 08:37 Zeljan Rikalo LazTarget => -
2014-04-11 08:37 Zeljan Rikalo Note Added: 0074293
2014-04-11 08:37 Zeljan Rikalo Status assigned => feedback
2014-04-11 11:31 Vojtech Cihak Note Added: 0074297
2014-04-11 11:31 Vojtech Cihak Status feedback => assigned
2014-04-12 08:28 Zeljan Rikalo Fixed in Revision => 44693
2014-04-12 08:28 Zeljan Rikalo Note Added: 0074335
2014-04-12 08:28 Zeljan Rikalo Status assigned => resolved
2014-04-12 08:28 Zeljan Rikalo Resolution open => fixed
2014-04-12 10:30 Vojtech Cihak Note Added: 0074339
2014-04-12 10:30 Vojtech Cihak Status resolved => closed
2014-05-17 23:10 Zeljan Rikalo Note Added: 0075050
2014-05-17 23:10 Zeljan Rikalo Status closed => assigned
2014-05-17 23:10 Zeljan Rikalo Resolution fixed => reopened
2014-05-17 23:12 Zeljan Rikalo Fixed in Revision 44693 => 44693,45064
2014-05-17 23:12 Zeljan Rikalo LazTarget - => 1.2.4
2014-05-17 23:12 Zeljan Rikalo Note Added: 0075051
2014-05-17 23:12 Zeljan Rikalo Status assigned => resolved
2014-05-17 23:12 Zeljan Rikalo Resolution reopened => fixed
2014-05-17 23:32 Zeljan Rikalo Note Added: 0075052
2014-05-18 09:19 Zeljan Rikalo Status resolved => feedback
2014-05-18 09:20 Zeljan Rikalo Fixed in Revision 44693,45064 => 44693,45066
2014-05-18 09:20 Zeljan Rikalo Note Added: 0075056
2014-05-18 09:20 Zeljan Rikalo Status feedback => resolved
2014-05-18 13:16 Vojtech Cihak Note Added: 0075066
2014-05-18 13:16 Vojtech Cihak Status resolved => closed
2014-06-16 09:46 Zeljan Rikalo Relationship added related to 0026342
2014-09-19 16:00 Vincent Snijders Relationship added related to 0026745
2014-09-20 09:43 Juha Manninen Relationship added related to 0026744