New plugin API

Ankit Vani a at
Sat Aug 10 05:28:04 EDT 2013

Hi Richard

On 9 August 2013 19:44, Richard Laager <rlaager at> wrote:
> On Fri, 2013-08-09 at 17:35 +0530, Ankit Vani wrote:
>> GPlugin refs everything before returning it to us. So basically you
>> would need to do things like:
>> GPluginPluginInfo *info = gplugin_plugin_get_info(plugin);
>> if (!gplugin_plugin_info_get_name()) {
>>     g_object_unref(info);
>>     return FALSE;
>> }
>> g_object_unref(info);
>> return TRUE;
> Yes, do things like that. Don't use things after unref()ing them. Even
> if it works now, it's not guaranteed to stay working. And it sets a bad
> example for others that might read that code and copy the pattern
> elsewhere with other types of objects.

After some thought and a talk with Gary, I believe it wouldn't hurt to use
transfer full for all our GObjectified entities after all. This would actually
allow libpurple to never worry about invalid pointers and stuff, and memory
management actually becomes easier. Although, mistakes do become much easier to
make, and there are many problems to this right now (e.g. account->gc and

As I said I don't think we should be using different semantics for different
entities, that would just lead to confusion. Given that, if we were to make
things transfer full, it should only be done after the full GObjectification of
purple. What do you say?

Of course since we are single-threaded, I still lean towards the simpler option
to keep using transfer none unless required as we are doing now, and ref things
for callbacks. Plugins can g_object_weak_ref() objects so that they don't get
deleted from under them.

                                                                         - Ankit

More information about the Devel mailing list