[gnome-builder] gtk: be more flexible with NULL widgets



commit da50e3e9c91a732042577bc06a214de320607bfd
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jan 6 02:19:17 2018 -0800

    gtk: be more flexible with NULL widgets

 src/libide/util/ide-gtk.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/libide/util/ide-gtk.c b/src/libide/util/ide-gtk.c
index aa0e087..f004cb6 100644
--- a/src/libide/util/ide-gtk.c
+++ b/src/libide/util/ide-gtk.c
@@ -146,17 +146,18 @@ ide_widget_message (gpointer     instance,
                     ...)
 {
   g_autofree gchar *str = NULL;
-  IdeContext *context;
+  IdeContext *context = NULL;
   va_list args;
 
   g_return_if_fail (IDE_IS_MAIN_THREAD ());
-  g_return_if_fail (GTK_IS_WIDGET (instance));
+  g_return_if_fail (!instance || GTK_IS_WIDGET (instance));
 
   va_start (args, format);
   str = g_strdup_vprintf (format, args);
   va_end (args);
 
-  context = ide_widget_get_context (instance);
+  if (instance != NULL)
+    context = ide_widget_get_context (instance);
 
   if (context != NULL)
     ide_context_emit_log (context, G_LOG_LEVEL_MESSAGE, str, -1);
@@ -170,17 +171,18 @@ ide_widget_warning (gpointer     instance,
                     ...)
 {
   g_autofree gchar *str = NULL;
-  IdeContext *context;
+  IdeContext *context = NULL;
   va_list args;
 
   g_return_if_fail (IDE_IS_MAIN_THREAD ());
-  g_return_if_fail (GTK_IS_WIDGET (instance));
+  g_return_if_fail (!instance || GTK_IS_WIDGET (instance));
 
   va_start (args, format);
   str = g_strdup_vprintf (format, args);
   va_end (args);
 
-  context = ide_widget_get_context (instance);
+  if (instance != NULL)
+    context = ide_widget_get_context (instance);
 
   if (context != NULL)
     ide_context_emit_log (context, G_LOG_LEVEL_WARNING, str, -1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]