mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-05 10:38:08 +01:00
1c6cd5f0a3
Some GNOME projects unconditionally work around the generated code's lack of g_autoptr support by defining the autoptr cleanup function themselves, which is not forward-compatible; as a result, commit cbbcaa4 broke them. Do not define the cleanup function unless the including app "opts in" to newer APIs via GLIB_VERSION_MAX_ALLOWED. Projects requiring compatibility with GLib < 2.49 can get a forward-compatible g_autoptr for a generated GInterface type found in a library, for example ExampleAnimal in the GIO tests, by declaring and using a typedef with a distinct name outside the library's namespace: typedef AutoExampleAnimal ExampleAnimal; G_DEFINE_AUTOPTR_CLEANUP_FUNC (AutoExampleAnimal, g_object_unref) ... g_autoptr (AutoExampleAnimal) animal = NULL; /* returns ExampleAnimal * */ animal = example_animal_proxy_new_sync (...); /* takes ExampleAnimal * first argument */ example_animal_call_poke_sync (animal, ...); Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugzilla.gnome.org/show_bug.cgi?id=763379 Reviewed-by: Colin Walters <walters@verbum.org> Reviewed-by: Emmanuele Bassi <ebassi@gnome.org>