[metacity] util: replace meta_bug with g_error



commit 1d252b3e095ffeef9201d25e72e65d4dfc654a52
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Mar 10 14:11:12 2017 +0200

    util: replace meta_bug with g_error

 src/core/core.c        |   15 ++++++++-------
 src/core/display.c     |    4 ++--
 src/core/keybindings.c |    2 +-
 src/core/prefs.c       |   10 +++++-----
 src/core/screen.c      |    4 ++--
 src/core/session.c     |    2 +-
 src/core/stack.c       |    6 +++---
 src/core/util.c        |   27 ---------------------------
 src/core/window.c      |    4 ++--
 src/core/workspace.c   |   12 +++++++-----
 src/core/xprops.c      |    2 +-
 src/include/util.h     |    2 --
 src/ui/frames.c        |    2 +-
 13 files changed, 33 insertions(+), 59 deletions(-)
---
diff --git a/src/core/core.c b/src/core/core.c
index 407a4e1..0bfcc71 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -51,7 +51,7 @@ get_window (Display *xdisplay,
 
   if (window == NULL || window->frame == NULL)
     {
-      meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
+      g_error ("No such frame window 0x%lx!", frame_xwindow);
       return NULL;
     }
 
@@ -60,8 +60,8 @@ get_window (Display *xdisplay,
 
 void
 meta_core_get (Display *xdisplay,
-    Window xwindow,
-    ...)
+               Window   xwindow,
+               ...)
 {
   va_list args;
   MetaCoreGetType request;
@@ -85,10 +85,11 @@ meta_core_get (Display *xdisplay,
    */
 
   if (request != META_CORE_WINDOW_HAS_FRAME &&
-      (window == NULL || window->frame == NULL)) {
-    meta_bug ("No such frame window 0x%lx!\n", xwindow);
-    goto out;
-  }
+      (window == NULL || window->frame == NULL))
+    {
+      g_error ("No such frame window 0x%lx!", xwindow);
+      goto out;
+    }
 
   while (request != META_CORE_GET_END) {
 
diff --git a/src/core/display.c b/src/core/display.c
index aaf8ca3..69b4b29 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -822,7 +822,7 @@ meta_display_close (MetaDisplay *display,
     }
 
   if (display->error_traps > 0)
-    meta_bug ("Display closed with error traps pending\n");
+    g_error ("Display closed with error traps pending");
 
   display->closing += 1;
 
@@ -931,7 +931,7 @@ void
 meta_display_ungrab (MetaDisplay *display)
 {
   if (display->server_grab_count == 0)
-    meta_bug ("Ungrabbed non-grabbed server\n");
+    g_error ("Ungrabbed non-grabbed server");
 
   display->server_grab_count -= 1;
   if (display->server_grab_count == 0)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 784c6ad..847c972 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -1210,7 +1210,7 @@ process_event (MetaKeyBinding       *bindings,
                   event->xkey.keycode, event->xkey.state);
 
       if (handler == NULL)
-        meta_bug ("Binding %s has no handler\n", bindings[i].name);
+        g_error ("Binding %s has no handler", bindings[i].name);
       else
         meta_topic (META_DEBUG_KEYBINDINGS,
                     "Running handler for %s\n",
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 73c1f48..808c1ad 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -485,7 +485,7 @@ handle_preference_init_string (void)
       if (cursor->handler)
         {
           if (cursor->target)
-            meta_bug ("%s has both a target and a handler\n", cursor->base.key);
+            g_error ("%s has both a target and a handler", cursor->base.key);
 
           g_settings_get_mapped (SETTINGS (cursor->base.schema),
                                  cursor->base.key, cursor->handler, NULL);
@@ -493,7 +493,7 @@ handle_preference_init_string (void)
       else
         {
           if (!cursor->target)
-            meta_bug ("%s must have handler or target\n", cursor->base.key);
+            g_error ("%s must have handler or target", cursor->base.key);
 
           if (*(cursor->target))
             g_free (*(cursor->target));
@@ -598,7 +598,7 @@ handle_preference_update_string (GSettings *settings,
   if (cursor->handler)
     {
       if (cursor->target)
-        meta_bug ("%s has both a target and a handler\n", cursor->base.key);
+        g_error ("%s has both a target and a handler", cursor->base.key);
 
       g_settings_get_mapped (SETTINGS (cursor->base.schema),
                              cursor->base.key, cursor->handler, NULL);
@@ -606,7 +606,7 @@ handle_preference_update_string (GSettings *settings,
   else
     {
       if (!cursor->target)
-        meta_bug ("%s must have handler or target\n", cursor->base.key);
+        g_error ("%s must have handler or target", cursor->base.key);
 
       value = g_settings_get_string (SETTINGS (cursor->base.schema),
                                      cursor->base.key);
@@ -686,7 +686,7 @@ meta_prefs_remove_listener (MetaPrefsChangedFunc func,
       tmp = tmp->next;
     }
 
-  meta_bug ("Did not find listener to remove\n");
+  g_error ("Did not find listener to remove");
 }
 
 static void
diff --git a/src/core/screen.c b/src/core/screen.c
index b384ec7..350a5af 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -2208,8 +2208,8 @@ meta_screen_calc_workspace_layout (MetaScreen          *screen,
     }
 
   if (i != grid_area)
-    meta_bug ("did not fill in the whole workspace grid in %s (%d filled)\n",
-              G_STRFUNC, i);
+    g_error ("did not fill in the whole workspace grid in %s (%d filled)",
+             G_STRFUNC, i);
 
   current_row = 0;
   current_col = 0;
diff --git a/src/core/session.c b/src/core/session.c
index 5c23bbb..c6fa31f 100644
--- a/src/core/session.c
+++ b/src/core/session.c
@@ -292,7 +292,7 @@ meta_session_init (const char *previous_client_id,
   else
     {
       if (client_id == NULL)
-        meta_bug ("Session manager gave us a NULL client ID?");
+        g_error ("Session manager gave us a NULL client ID?");
       meta_topic (META_DEBUG_SM, "Obtained session ID '%s'\n", client_id);
     }
 
diff --git a/src/core/stack.c b/src/core/stack.c
index 18ef333..c0fcdbd 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -110,7 +110,7 @@ meta_stack_add (MetaStack  *stack,
   meta_topic (META_DEBUG_STACK, "Adding window %s to the stack\n", window->desc);
 
   if (window->stack_position >= 0)
-    meta_bug ("Window %s had stack position already\n", window->desc);
+    g_error ("Window %s had stack position already", window->desc);
 
   stack->added = g_list_prepend (stack->added, window);
 
@@ -130,8 +130,8 @@ meta_stack_remove (MetaStack  *stack,
   meta_topic (META_DEBUG_STACK, "Removing window %s from the stack\n", window->desc);
 
   if (window->stack_position < 0)
-    meta_bug ("Window %s removed from stack but had no stack position\n",
-              window->desc);
+    g_error ("Window %s removed from stack but had no stack position",
+             window->desc);
 
   /* Set window to top position, so removing it will not leave gaps
    * in the set of positions
diff --git a/src/core/util.c b/src/core/util.c
index 1b28d33..f07d2b6 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -285,33 +285,6 @@ meta_topic (MetaDebugTopic  topic,
 }
 
 void
-meta_bug (const char *format, ...)
-{
-  va_list args;
-  gchar *str;
-  FILE *out;
-
-  g_return_if_fail (format != NULL);
-
-  va_start (args, format);
-  str = g_strdup_vprintf (format, args);
-  va_end (args);
-
-  out = logfile ? logfile : stderr;
-
-  if (no_prefix == 0)
-    utf8_fputs (_("Bug in window manager: "), out);
-  utf8_fputs (str, out);
-
-  fflush (out);
-
-  g_free (str);
-
-  /* stop us in a debugger */
-  abort ();
-}
-
-void
 meta_fatal (const char *format, ...)
 {
   va_list args;
diff --git a/src/core/window.c b/src/core/window.c
index e2a2d36..a80a3da 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1048,8 +1048,8 @@ meta_window_free (MetaWindow  *window,
     }
 
   if (destroying_windows_disallowed > 0)
-    meta_bug ("Tried to destroy window %s while destruction was not allowed\n",
-              window->desc);
+    g_error ("Tried to destroy window %s while destruction was not allowed",
+             window->desc);
 
   window->unmanaging = TRUE;
 
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 3e150f2..dc912c8 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -328,7 +328,7 @@ static void workspace_switch_sound(MetaWorkspace *from,
       break;
 
   if (i >= nw) {
-    meta_bug("Failed to find destination workspace in layout\n");
+    g_error ("Failed to find destination workspace in layout");
     goto finish;
   }
 
@@ -343,7 +343,7 @@ static void workspace_switch_sound(MetaWorkspace *from,
      movement but not such much vertical movement. */
 
   if (x == layout.current_col && y == layout.current_row) {
-    meta_bug("Uh, origin and destination workspace at same logic position!\n");
+    g_error ("Uh, origin and destination workspace at same logic position!");
     goto finish;
   }
 
@@ -469,7 +469,7 @@ meta_workspace_index (MetaWorkspace *workspace)
   ret = g_list_index (workspace->screen->workspaces, workspace);
 
   if (ret < 0)
-    meta_bug ("Workspace does not exist to index!\n");
+    g_error ("Workspace does not exist to index!");
 
   return ret;
 }
@@ -865,8 +865,10 @@ meta_workspace_get_neighbor (MetaWorkspace      *workspace,
     i = current_space;
 
   if (i >= num_workspaces)
-    meta_bug ("calc_workspace_layout left an invalid (too-high) workspace number %d in the grid\n",
-              i);
+    {
+      g_error ("calc_workspace_layout left an invalid (too-high) workspace "
+               "number %d in the grid", i);
+    }
 
   meta_verbose ("Neighbor workspace is %d at row %d col %d\n",
                 i, layout.current_row, layout.current_col);
diff --git a/src/core/xprops.c b/src/core/xprops.c
index 428b51f..0cadb46 100644
--- a/src/core/xprops.c
+++ b/src/core/xprops.c
@@ -1017,7 +1017,7 @@ meta_prop_get_values (MetaDisplay   *display,
                * property notify on an atom we don't care about.
                */
               if (values[i].atom != None)
-                meta_bug ("META_PROP_VALUE_INVALID requested in %s\n", G_STRFUNC);
+                g_error ("META_PROP_VALUE_INVALID requested in %s", G_STRFUNC);
               break;
             case META_PROP_VALUE_UTF8_LIST:
             case META_PROP_VALUE_UTF8:
diff --git a/src/include/util.h b/src/include/util.h
index 436043c..d54a150 100644
--- a/src/include/util.h
+++ b/src/include/util.h
@@ -38,8 +38,6 @@ void     meta_set_replace_current_wm (gboolean setting);
 void meta_verbose (const char *format,
                    ...) G_GNUC_PRINTF (1, 2);
 
-void meta_bug        (const char *format,
-                      ...) G_GNUC_PRINTF (1, 2);
 void meta_fatal      (const char *format,
                       ...) G_GNUC_PRINTF (1, 2);
 
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 116f99d..a323d3d 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -883,7 +883,7 @@ meta_frames_get_borders (MetaFrames       *frames,
   frame = meta_frames_lookup_window (frames, xwindow);
 
   if (frame == NULL)
-    meta_bug ("No such frame 0x%lx\n", xwindow);
+    g_error ("No such frame 0x%lx", xwindow);
 
   meta_ui_frame_get_borders (frames, frame, borders);
 }


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