GLib/GObject+C as the lingua franca?

Ingo Klöcker kloecker at
Sun Jul 27 21:51:53 BST 2008

On Sunday 27 July 2008, nf2 wrote:
> koos vriezen wrote:
> > 2008/7/27 nf2 <nf2 at>:
> >> I thought of really lightweight wrapping. Very minimalistic. See
> >> the example below. Mainly that you can put GObjects into C++
> >> containers and for garbage collection...
> >
> > But you also need to add a copy constructor then and think about
> > either implicit sharing the GFile object or copying ... GFile
> > doesn't seem to have ref counting only g_file_dup, so for sharing
> > you must do your own ref counting.
> GFile inherits from GObject. Therefore it does have ref-counting.
> > But if you can easily track the file objects, why not simply store
> > the pointers in the C++ containers.
> Again - garbage collection.
> The attached example implements the "GO" template class and tests it
> a little - valgrind reports 0 leaks :-)
> A bit like a C++ class with QExplicitlySharedDataPointer.

There's no need to reinvent the wheel:

I doubt people would be happy if you'd introduce a dependency on boost, 
but you could still copy the well-tried implementation of 
boost::intrusive_ptr<T> instead of rolling your own implementation.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list