GNOME Bugzilla – Bug 128410
GDI object leak in reorderable GtkTreeView
Last modified: 2004-12-22 21:47:04 UTC
I will attach a small test program that demonstrates a GDI object leak in a reorderable GtkTreeView when dragging rows. On my system, the program starts with 44 GDI objects (accoding to the task manager). When I click on a row and start dragging the number of GDI objects goes up every time something is redrawn, rapidly reaching 60 and still climbing. I can't quite tell what redraw is causing this leak right now, but I will keep looking.
Created attachment 22035 [details] simple test case demostrating this bug
I can now say exactly *when* (but not where or why) the leak occurs. Start by doing a few drags to initialize the permanent stuff, so that only the real leaks appear. Then drag the top row down slowly so that the drop indicator line appears below the first row. When that indicator appears two GDI objects are leaked. Then drag back up so that the indicator line disappears. At this point 1 more GDI object is leaked. This may not be the only place that leaks occur, but it is one place.
I found a very useful piece of code in this article: http://msdn.microsoft.com/msdnmag/issues/03/01/GDILeaks/default.aspx Using this "GdiUsage" program for Windows XP, I was able to find that the leaked objects are the bitmaps used for the drag-and-drop mouse pointers. I will attach a screenshot of the bitmaps that are leaking.
Created attachment 22077 [details] The bitmaps that are leaking
Created attachment 22079 [details] [review] patch against gtk+2.2.4 (gdk_pointer_grab) that fixes this bug
I don't think that is the correct fix. You are destroying the cursor pointed to by p_grab_cursor, and that is used later during the grab, in the WM_SETCURSOR handler. The pointer grab cursor is supposed to get destroyed in gdk_display_pointer_ungrab(). I think the real problem is that if gdk_pointer_grab is called multiple times without any call to _ungrab inbetween, the old grab cursor, if any, is leaked.
Created attachment 22117 [details] [review] Better patch
Yes, that looks better. Thanks.
Patch applied to HEAD and gtk-2-2.