GLib/GObject+C as the lingua franca?

Thiago Macieira thiago at
Sun Jul 27 22:05:55 BST 2008

Ingo Klöcker wrote:
>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.

I'm rolling out QSharedPointer which will have both shared_ptr and 
intrusive_ptr functionality for Qt 4.5.

There's no need for a Boost dependency.

  Thiago Macieira  -  thiago (AT) - thiago (AT)
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list