Add support for g_autoptr() to our types

g_autoptr() is a macro that was defined in GLib 2.44 that allows for
basic auto-cleanup of variables. One way to add this kind of support
would be through the use of e.g. `G_DECLARE_DERIVABLE_TYPE()` for our
declarations, but this would consitute an ABI break (due to the
`...Private *` field in the public structs). Instead, we can use
`G_DEFINE_AUTOPTR_CLEANUP_FUNC` to manually declare this.

This commit also bumps the minimally required GLib version to 2.44
This commit is contained in:
Niels De Graef 2019-01-19 11:57:22 +01:00
parent 92e9952ba2
commit 80afd20c19
8 changed files with 19 additions and 3 deletions

View File

@ -9,9 +9,9 @@ dnl Dependency versions
# Required # Required
GLIB_REQ=2.38.0 GLIB_REQ=2.44.0
GLIB_MIN=GLIB_VERSION_2_38 GLIB_MIN=GLIB_VERSION_2_44
GLIB_MAX=GLIB_VERSION_2_38 GLIB_MAX=GLIB_VERSION_2_44
# Optional # Optional

View File

@ -173,6 +173,8 @@ guint64 secret_collection_get_created (SecretCollection
guint64 secret_collection_get_modified (SecretCollection *self); guint64 secret_collection_get_modified (SecretCollection *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretCollection, g_object_unref);
G_END_DECLS G_END_DECLS
#endif /* __SECRET_COLLECTION_H___ */ #endif /* __SECRET_COLLECTION_H___ */

View File

@ -191,6 +191,8 @@ guint64 secret_item_get_created (SecretItem *self);
guint64 secret_item_get_modified (SecretItem *self); guint64 secret_item_get_modified (SecretItem *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretItem, g_object_unref);
G_END_DECLS G_END_DECLS
#endif /* __SECRET_ITEM_H___ */ #endif /* __SECRET_ITEM_H___ */

View File

@ -56,6 +56,8 @@ SecretSync * _secret_sync_new (void);
void _secret_sync_free (gpointer data); void _secret_sync_free (gpointer data);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSync, _secret_sync_free)
void _secret_sync_on_result (GObject *source, void _secret_sync_on_result (GObject *source,
GAsyncResult *result, GAsyncResult *result,
gpointer user_data); gpointer user_data);
@ -185,6 +187,8 @@ gchar * _secret_value_unref_to_string (SecretValue *valu
void _secret_session_free (gpointer data); void _secret_session_free (gpointer data);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSession, _secret_session_free)
const gchar * _secret_session_get_algorithms (SecretSession *session); const gchar * _secret_session_get_algorithms (SecretSession *session);
const gchar * _secret_session_get_path (SecretSession *session); const gchar * _secret_session_get_path (SecretSession *session);

View File

@ -75,6 +75,8 @@ GVariant * secret_prompt_perform_finish (SecretPrompt *self,
GAsyncResult *result, GAsyncResult *result,
GError **error); GError **error);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretPrompt, g_object_unref);
G_END_DECLS G_END_DECLS
#endif /* __SECRET_PROMPT_H___ */ #endif /* __SECRET_PROMPT_H___ */

View File

@ -72,6 +72,8 @@ void secret_schema_unref (SecretSchema *schema);
GType secret_schema_attribute_get_type (void) G_GNUC_CONST; GType secret_schema_attribute_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSchema, g_object_unref);
G_END_DECLS G_END_DECLS
#endif /* __SECRET_SCHEMA_H___ */ #endif /* __SECRET_SCHEMA_H___ */

View File

@ -304,6 +304,8 @@ gboolean secret_service_set_alias_sync (SecretService
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretService, g_object_unref);
G_END_DECLS G_END_DECLS
#endif /* __SECRET_SERVICE_H___ */ #endif /* __SECRET_SERVICE_H___ */

View File

@ -51,6 +51,8 @@ SecretValue * secret_value_ref (SecretValue *value);
void secret_value_unref (gpointer value); void secret_value_unref (gpointer value);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretValue, secret_value_unref);
G_END_DECLS G_END_DECLS
#endif /* __SECRET_VALUE_H___ */ #endif /* __SECRET_VALUE_H___ */