GNOME Bugzilla – Bug 344137
Document that wnck objects are owned by libwnck
Last modified: 2011-02-18 17:12:18 UTC
Steps to reproduce: 1. download the attached file 2. compile it (gcc -o demo main.c `pkg-config --cflags --libs libwnck-1.0`) 3. run it, open a window, close it 4. take a look at the application, it has crashed Stack trace:
+ Trace 68702
Other information: An attachment, will attach it...
Created attachment 66906 [details] testcase Here's the attachment.
Remove the g_object_unref() and it seems to work just fine. :) The g_object_unref() doesn't look like it can be right since libwnck/screen.c keeps a static WnckScreen **screens around, and just returns the ith member of it whenever someone asks for a screen. By unrefing it, it looks like you're freeing the memory, but you aren't fixing up the screens array and thus the next person who comes along would get a pointer to free'd data. But, somewhat embarrassingly, I've never bothered to figure out how all the gobject stuff interacts, so you'll have to take what I say with a grain of salt. And get someone else to look over it for what, if anything, needs to actually be done in wnck. It looks like the screens struct is never freed/cleared, so it appears we need to at least do that somewhere (at least for valgrind cleanness).
From my understanding, Wnck is completely static in the sense that it creates all objects itself and keeps all references for itself. So no Wnck object ever needs to be reffed/unreffed. I don't even know what happens if you keep a reference to a WnckFoo struct and access it after it was already "destroyed" by Wnck. This is btw how I'd expect it to behave, but it probably needs to be documented.
Should this be moved to the docs component (it does not exist ;-) )?
Other point: I'm using libwnck to provide a window selection. Shouldn't it be possible to wnck_shutdown() when I'm done?
Moving to shiny new docs component. (In reply to comment #5) > Other point: I'm using libwnck to provide a window selection. Shouldn't it be > possible to wnck_shutdown() when I'm done? Hrm, interesting idea. I've nothing against it, except that it should be filed as a new bug of course :-)
I split the part about wnck_shutdown() in bug 642692. And I finally added some documentation.