[gnome-builder] object: allow checking if context hold succeeded
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] object: allow checking if context hold succeeded
- Date: Sun, 17 May 2015 03:15:30 +0000 (UTC)
commit 6d280f13e13aab64b580c77d0092a8571f882297
Author: Christian Hergert <christian hergert me>
Date: Sat May 16 20:11:42 2015 -0700
object: allow checking if context hold succeeded
libide/ide-object.c | 19 ++++++++++++-------
libide/ide-object.h | 2 +-
2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/libide/ide-object.c b/libide/ide-object.c
index 7c54897..2fcf9e5 100644
--- a/libide/ide-object.c
+++ b/libide/ide-object.c
@@ -375,28 +375,33 @@ ide_object_new_finish (GAsyncResult *result,
*
* You should call ide_object_release() an equivalent number of times to
* ensure the context may be freed afterwards.
+ *
+ * You should check the return value of this function to ensure that the
+ * context is not already in shutdown.
+ *
+ * Returns: %TRUE if a hold was successfully created.
*/
-void
+gboolean
ide_object_hold (IdeObject *self)
{
IdeObjectPrivate *priv = ide_object_get_instance_private (self);
- g_return_if_fail (IDE_IS_OBJECT (self));
+ g_return_val_if_fail (IDE_IS_OBJECT (self), FALSE);
- if (priv->context == NULL)
+ if (priv->context != NULL)
{
- IDE_BUG ("libide", "Called after context was released.");
- return;
+ ide_context_hold (priv->context);
+ return TRUE;
}
- ide_context_hold (priv->context);
+ return FALSE;
}
/**
* ide_object_release:
* @self: the #IdeObject.
*
- * Releases a hold on the context previously called with ide_object_hold().
+ * Releases a successful hold on the context previously created with ide_object_hold().
*/
void
ide_object_release (IdeObject *self)
diff --git a/libide/ide-object.h b/libide/ide-object.h
index d1e768c..325dc63 100644
--- a/libide/ide-object.h
+++ b/libide/ide-object.h
@@ -46,7 +46,7 @@ void ide_object_new_async (const gchar *extension_point,
...);
IdeObject *ide_object_new_finish (GAsyncResult *result,
GError **error);
-void ide_object_hold (IdeObject *self);
+gboolean ide_object_hold (IdeObject *self);
void ide_object_release (IdeObject *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]