GLib/GObject+C as the lingua franca?

Kevin Krammer kevin.krammer at gmx.at
Sun Jul 27 23:45:21 BST 2008


On Sunday 27 July 2008, nf2 wrote:

[snip]

>     GO &operator=(const GO &other)
>     {
>         if (p != NULL)
>         {
>             g_object_unref(p);
>         }
>         p = other.p;
>         g_object_ref(p);
>         return *this;
>     }

Assignment operators should always check for self-assignment first, otherwise 
bad things might happen, like in this case where p gets deleted if the object 
is the only reference to it.

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- 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: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080728/b947fb57/attachment.sig>


More information about the kde-core-devel mailing list