Re: [Bug 111028] Dealing with reference cycles in GObject



On 2003.04.25 23:43 Tor Lillqvist wrote:
J. Ali Harlow writes:
 > I found that the GdkPixmap->GdkImage reference really isn't
 > important. It's only really there to have somewhere convenient to
 > store the location of the pixel data in the pixmap and as an easy
 > way of accessing the dimensions of that data.

Yup.

(On the other hand, even with your fix, can't one also say that the
GdkImage->GdkPixmap reference is only there to have a convenient
holder for the pixel data in the image. It also makes the blitting
code simpler, as it only has to handle windows and pixmaps.)

Certainly. The point being that a reference cycle is awkward to deal
with (but not impossible) whereas a simple reference from one to the
other is trivial to deal with.

 > I have therefore put together a fix which removes this reference
 > entirely which seems to solve the problem.

Your fix seems straightforward enough, and removes some
complexity. (On the other hand it duplicates the pixel pointer for
GdkImages, it is now both in image::mem and pixmap::bits. No big
deal.) If it indeed fixes a problem and doesn't cause any new ones,
I'm all for applying it.

(Have you tested your fix in 256-colour mode?)

I can't claim to have tested it anything like well enough for it
to be committed without more work - sorry. It does fix the problem
that I reported with the critical error messages from g_object_unref
and it does seem to work in the application that was causing me
problems. I implemented code to maintain gdkimage-win32!image_list
and added a hack to access the list. I did the same to access the
win32 handle hash table. On exit from the application (specifically
in the main window destroy handler) the counts for images and handles
rise quickly to 1 and 34 respectively and then stay constant so I
don't think there are any leaks in my fix.

I've only run the application on a 32-bit graphic mode under XP.

--
Ali Harlow                              Email: ali avrc city ac uk
Research programmer                     Tel:   (020) 7040 4348
Applied Vision Research Centre          Intl: +44 20 7040 4348
City University                         Fax:   (020) 7040 5515
London                                  Intl: +44 20 7040 5515



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]