[gnome-builder] libide-core: add ide_object_check_ready()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide-core: add ide_object_check_ready()
- Date: Tue, 12 Jul 2022 06:39:08 +0000 (UTC)
commit 3cd3961c34d563d92bea83572dcaa3d811b5403f
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 11 16:32:47 2022 -0700
libide-core: add ide_object_check_ready()
This is a helper to see if the object is connected to the context.
src/libide/core/ide-object.c | 29 +++++++++++++++++++++++++++++
src/libide/core/ide-object.h | 3 +++
2 files changed, 32 insertions(+)
---
diff --git a/src/libide/core/ide-object.c b/src/libide/core/ide-object.c
index f19515e06..7c40f680a 100644
--- a/src/libide/core/ide-object.c
+++ b/src/libide/core/ide-object.c
@@ -1310,3 +1310,32 @@ ide_object_log (gpointer instance,
va_end (args);
}
}
+
+gboolean
+ide_object_check_ready (IdeObject *self,
+ GError **error)
+{
+ IdeObjectPrivate *priv = ide_object_get_instance_private (self);
+ g_autoptr(IdeObject) root = NULL;
+
+ if (self == NULL ||
+ priv->in_destruction ||
+ priv->destroyed)
+ goto failure;
+
+ if (!(root = ide_object_ref_root (self)))
+ goto failure;
+
+ if (!IDE_IS_CONTEXT (root))
+ goto failure;
+
+ return TRUE;
+
+failure:
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ "Operation cancelled or in shutdown");
+
+ return FALSE;
+}
diff --git a/src/libide/core/ide-object.h b/src/libide/core/ide-object.h
index 7abaedeb3..c65750dcf 100644
--- a/src/libide/core/ide-object.h
+++ b/src/libide/core/ide-object.h
@@ -149,6 +149,9 @@ void ide_object_log (gpointer instance,
const gchar *domain,
const gchar *format,
...) G_GNUC_PRINTF (4, 5);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_object_check_ready (IdeObject *self,
+ GError **error);
#ifdef __cplusplus
#define ide_object_message(instance, format, ...) ide_object_log(instance, G_LOG_LEVEL_MESSAGE,
G_LOG_DOMAIN, format __VA_OPT__(,) __VA_ARGS__)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]