[mutter/meego-1.0: 21/30] Only bail out on managing a specific window for valid reasons, MB#21



commit 253f46f98a631a092873e4594e6b0d37a93a759f
Author: Tomas Frydrych <tf linux intel com>
Date:   Tue Apr 20 15:54:53 2010 +0100

    Only bail out on managing a specific window for valid reasons, MB#21
    
    MB#21 was due to meta_window_new() failing as a result of catching BadColor
    error when querying the window attributes; in fact this error was left over
    from a previous operations on a different window. This commit makes creation of
    MetaWindow bit more robust so we bail out only on errors that are valid for the
    XGetWindowAttributes() call.

 src/core/window.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 95566f4..1d0ef90 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -484,7 +484,18 @@ meta_window_new (MetaDisplay *display,
 
   if (XGetWindowAttributes (display->xdisplay,xwindow, &attrs))
    {
-      if(meta_error_trap_pop_with_return (display, TRUE) != Success)
+     int e = meta_error_trap_pop_with_return (display, TRUE);
+
+     /*
+      * HACK
+      *
+      * XGetWindowAttributes () is only supposed to generate BadWindow or
+      * BadDrawable errors; this test ensures that we do not bail out here if
+      * we catch some miscelaneous error that is unrelated to this call and
+      * was only flushed out be the trap. If we do, issue warning so we can
+      * investigate this further.
+      */
+     if (e == BadWindow || e == BadDrawable)
        {
           meta_verbose ("Failed to get attributes for window 0x%lx\n",
                         xwindow);
@@ -492,6 +503,9 @@ meta_window_new (MetaDisplay *display,
           meta_display_ungrab (display);
           return NULL;
        }
+     else if (e)
+       g_warning (G_STRLOC ": Caught unexpected error %d", e);
+
       window = meta_window_new_with_attrs (display, xwindow,
                                            must_be_viewable,
                                            META_COMP_EFFECT_CREATE,



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