Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-04

Canvas Save/RestoreHandleState not destroying gdiobjects (GTK2 Linux)

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

cobines

Hello.

I have a problem with Canvas.SaveHandleState and
Canvas.RestoreHandleState on GTK2. In my program I use TDrawGrid which uses the mentioned Save/Restore functions. I also do a drawing with many colors in another control, which causes frequent changes to the brush color while painting. After a few redraws I start getting such error messages:

TGtkWidgetSet.DeleteObject GdiObject=B1EC4440 gdiBrush is still used. DCCount=1 DC: B5D2D390 09967200=LCLWinapiClient [RMVDFStPrApDb] LCLObject=B5A76670=:TDrawGridEx<MainWidget=09966B58=LCLWinapiWidget><Is FixedWidget><Is CoreWidget>

And at the end of the program there's message:

[TGtkWidgetSet.Destroy] WARNING: There are 361 unreleased GDIObjects, a detailed dump follows:
[TGtkWidgetSet.Destroy] GDIOs: B6696E00 B6696CE0 B66967A0 B6696680 B6696140 B6696020 B66970A0
[TGtkWidgetSet.Destroy] gdiBrush: 361

I'm using Lazarus SVN trunk, FPC SVN trunk. I experience it with GTK 2.18 and GTK 2.20. I can reproduce the problem in small sample, but noticed something and wanted to ask first before posting bug report in Mantis.

The function writing the error is in lcl/interfaces/gtk/gtkwinapi.inc TGtkWidgetSet.DeleteObject: RaiseGDIObjectIsStillUsed. A comment inside there says:

"
    // do not raise an exception, because this is a common bug in many programs
    // just give a warning
"

Does anyone know what common bug does this comment refer to? Is this a bug in my program? I have attached the sample that causes these errors. Maybe someone can tell me if I'm not supposed to draw this way?

I checked and the bug doesn't happen with LCLQT.

cobines -------------- next part -------------- A non-text attachment was scrubbed... Name: canvas_restore.tar.bz2 Type: application/x-bzip2 Size: 2107 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100418/009f77a3/attachment.bin>

Reply by email

Mattias Gaertner
to cobines
Show quoted text 27 lines
Hello. I have a problem with Canvas.SaveHandleState and Canvas.RestoreHandleState on GTK2. In my program I use TDrawGrid which uses the mentioned Save/Restore functions. I also do a drawing with many colors in another control, which causes frequent changes to the brush color while painting. After a few redraws I start getting such error messages: TGtkWidgetSet.DeleteObject GdiObject=B1EC4440 gdiBrush is still used. DCCount=1 DC: B5D2D390 09967200=LCLWinapiClient [RMVDFStPrApDb] LCLObject=B5A76670=:TDrawGridEx<MainWidget=09966B58=LCLWinapiWidget><Is FixedWidget><Is CoreWidget> And at the end of the program there's message: [TGtkWidgetSet.Destroy] WARNING: There are 361 unreleased GDIObjects, a detailed dump follows: [TGtkWidgetSet.Destroy] GDIOs: B6696E00 B6696CE0 B66967A0 B6696680 B6696140 B6696020 B66970A0 [TGtkWidgetSet.Destroy] gdiBrush: 361 I'm using Lazarus SVN trunk, FPC SVN trunk. I experience it with GTK 2.18 and GTK 2.20. I can reproduce the problem in small sample, but noticed something and wanted to ask first before posting bug report in Mantis.

Please create a bug report with a small example.

Show quoted text 10 lines
The function writing the error is in lcl/interfaces/gtk/gtkwinapi.inc TGtkWidgetSet.DeleteObject: RaiseGDIObjectIsStillUsed. A comment inside there says: " // do not raise an exception, because this is a common bug in many programs // just give a warning " Does anyone know what common bug does this comment refer to?

Calling DeleteObject even though the object is still used in a device context.

Show quoted text 6 lines
Is this a bug in my program? I have attached the sample that causes these errors. Maybe someone can tell me if I'm not supposed to draw this way? I checked and the bug doesn't happen with LCLQT.

Mattias

Reply by email

cobines
to Mattias Gaertner

2010/4/18 Mattias Gaertner :

Show quoted text 15 lines
On Sun, 18 Apr 2010 13:00:48 +0200 cobines wrote: > The function writing the error is in lcl/interfaces/gtk/gtkwinapi.inc > TGtkWidgetSet.DeleteObject: RaiseGDIObjectIsStillUsed. A comment > inside there says: > > " > ? ? // do not raise an exception, because this is a common bug in many programs > ? ? // just give a warning > " > > Does anyone know what common bug does this comment refer to? Calling DeleteObject even though the object is still used in a device context.

Ah, I see. So, since I'm not using DeleteObject directly in my program this comment doesn't apply and must be a bug in Lazarus. Ok, thanks for clarifying. I'll create a bug report now.

cobines

Reply by email