Hi Axel, Andy, On Sat, Oct 23, 2010 at 09:56:00PM +0200, Axel Simon wrote: > On Oct 23, 2010, at 20:41, Andy Stewart wrote: > > > I think this is have internal trick in GIO C code that will break if > > we use wrapNewGObject in fileEnumeratorNextFile > > > > But makeNewGObject always works, so let's keep makeNewGObject.
That's a practical solution ;) But in C you should unref both the enumerator and its returned files to avoid a memory leak, why not in Haskell ? > If makeNewGObject works and wrapNewGObject does not, then > makeNewGObject is the correct one. makeNewGObject is used to wrap a > handle that is not new. As far as I understand this is the picture: > > function refs held action refs held > constructGObject f objectRefSink H > makeGObject C objectRef C,H > wrapGObject C none H > > The first "refs held" column indicates if C holds a floating reference > (f) or a real reference (C). Then the "action" is performed on the > object and afterwards the reference counts are held by Haskell "H", by > the C object "C" or by both. wrapGObject does not do anything to the > reference count, it simply takes the C reference count "C" and uses it > from Haskell "H". All three functions will add an unrefGObject call as > finalizers, so that the "H" reference is returned when the ForeignPtr > is garbage-collected. Yep, you got this right. > So if something crashes because you've changed a "makeGObject" to a > "wrapGObject" then it must be that "makeGObject" was needed since the > C object expects that it still holds a reference to the object. It could be, but if this was a problem with references, GLIB would probably smoothly terminate the program after displaying some error messages concerning ref/unref. It is not the case. Andy got a plain segfault and my "runghc Segfault.hs" (although Andy cannot reproduce it :( generated also some naughty backtrace. But again, I am stubborn and may be completely wrong. So I need to experiment more on this issue (like understanding why my Segfault.hs run fine with Andy). regards, /john ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Gtk2hs-devel mailing list Gtk2hs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel