diff mbox

[Branch,~glcompbench-dev/glcompbench/trunk] Rev 81: Merge in the fix for bug 984058.

Message ID 20120419142810.22878.95972.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker April 19, 2012, 2:28 p.m. UTC
Merge authors:
  Jesse Barker (jesse-barker)
Related merge proposals:
  https://code.launchpad.net/~glcompbench-dev/glcompbench/bug-984058/+merge/102594
  proposed by: Jesse Barker (jesse-barker)
------------------------------------------------------------
revno: 81 [merge]
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Thu 2012-04-19 07:25:08 -0700
message:
  Merge in the fix for bug 984058.
  
  Update the Canvas to handle the case where a window has been destroyed, but we
  receive other events on that window before we get the DestroyNotify.
modified:
  src/composite-canvas-egl.cc
  src/composite-canvas-glx.cc
  src/composite-canvas.cc
  src/composite-window.cc


--
lp:glcompbench
https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk

You are subscribed to branch lp:glcompbench.
To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/composite-canvas-egl.cc'
--- src/composite-canvas-egl.cc	2011-12-12 13:16:47 +0000
+++ src/composite-canvas-egl.cc	2012-04-17 23:19:42 +0000
@@ -301,6 +301,7 @@ 
 
     std::stringstream ss;
 
+    ss << "    EGL " << eglQueryString(egl_display_, EGL_VERSION) << std::endl;
     ss << "    OpenGL Information" << std::endl;
     ss << "    GL_VENDOR:     " << glGetString(GL_VENDOR) << std::endl;
     ss << "    GL_RENDERER:   " << glGetString(GL_RENDERER) << std::endl;

=== modified file 'src/composite-canvas-glx.cc'
--- src/composite-canvas-glx.cc	2011-12-09 16:09:11 +0000
+++ src/composite-canvas-glx.cc	2012-04-17 23:19:42 +0000
@@ -254,6 +254,7 @@ 
 
     std::stringstream ss;
 
+    ss << "    GLX " << glXGetClientString(xdpy_, GLX_VERSION) << std::endl;
     ss << "    OpenGL Information" << std::endl;
     ss << "    GL_VENDOR:     " << glGetString(GL_VENDOR) << std::endl;
     ss << "    GL_RENDERER:   " << glGetString(GL_RENDERER) << std::endl;

=== modified file 'src/composite-canvas.cc'
--- src/composite-canvas.cc	2012-03-09 03:58:54 +0000
+++ src/composite-canvas.cc	2012-04-19 14:15:59 +0000
@@ -368,7 +368,6 @@ 
 {
     XEvent event;
     bool needs_redraw(false);
-    Window window(0);
     Profiler::ScopedSamples xevent_scoped(CompositeCanvas::profiler_xevent_pair());
 
     if (Options::idle_redraw && !XPending(xdpy_))
@@ -376,16 +375,32 @@ 
 
     XNextEvent(xdpy_, &event);
 
-    if (event.type == damage_event_ + XDamageNotify) {
+    // We have to allow for the possibility that the window has actually
+    // been destroyed, but we saw the current event before the destroy event.
+    // So, check for a queued-up DestroyNotify event for our window before
+    // trying to update (bug 984058).
+    Window window = event.xany.window;
+    XEvent destroyEvent;
+    if (True == XCheckTypedWindowEvent(xdpy_, window, DestroyNotify, &destroyEvent)) {
+        Log::debug("--- Destroy Win: 0x%x\n", window);
+        remove_window(window);
+        // If we're using a user provided list of windows, prune this one
+        // out to make sure we don't create any new objects with a bad
+        // window list.
+        if (!Options::window_ids.empty())
+        {
+            Options::window_ids.remove(window);
+        }
+        needs_redraw = true;
+    }
+    else if (event.type == damage_event_ + XDamageNotify) {
         // This is a little ugly, but then so is violating strict aliasing
         // to make the hideous cast to reference this as an XDamageNotifyEvent.
-        window = event.xany.window;
         Log::debug("### Damage Win: 0x%x\n", window);
         handle_damage(window);
         needs_redraw = true;
     }
     else if (event.type == ConfigureNotify) {
-        window = event.xconfigure.window;
         Log::debug("Configure Win: 0x%x %d x %d\n",
                    window,
                    width_, height_);
@@ -398,24 +413,20 @@ 
             update_window(window);
     }
     else if (event.type == Expose) {
-        window = event.xexpose.window;
         Log::debug("Expose Win: 0x%x\n", window);
         needs_redraw = true;
     }
     else if (event.type == UnmapNotify) {
-        window = event.xunmap.window;
         Log::debug("--- Unmap Win: 0x%x\n", window);
         update_window(window);
         needs_redraw = true;
     }
     else if (event.type == MapNotify) {
-        window = event.xmap.window;
         Log::debug("+++ Map Win: 0x%x\n", window);
         update_window(window);
         needs_redraw = true;
     }
     else if (event.type == ReparentNotify) {
-        window = event.xreparent.window;
         Window parent = event.xreparent.parent;
         Log::debug("+++ Reparent Win: 0x%x Parent: 0x%x\n", parent);
         if (parent == root_)
@@ -425,13 +436,11 @@ 
         needs_redraw = true;
     }
     else if (event.type == CreateNotify) {
-        window = event.xcreatewindow.window;
         Log::debug("+++ Add Win: 0x%x Parent: 0x%x\n",
                    window, event.xcreatewindow.parent);
         add_window(window);
     }
     else if (event.type == DestroyNotify) {
-        window = event.xdestroywindow.window;
         Log::debug("--- Destroy Win: 0x%x\n", window);
         remove_window(window);
         needs_redraw = true;

=== modified file 'src/composite-window.cc'
--- src/composite-window.cc	2011-08-03 14:34:10 +0000
+++ src/composite-window.cc	2012-04-17 23:17:20 +0000
@@ -34,7 +34,7 @@ 
     if (pix_)
         XFreePixmap(xdpy_, pix_);
 
-    if (damage_)
+    if (damage_ && attr_.map_state == IsUnmapped)
         XDamageDestroy(xdpy_, damage_);
 }
 
@@ -72,12 +72,12 @@ 
               width_, height_, attr_.map_state);
 
     /* Update pixmap */
-    if (!pix_ && attr_.map_state != 0) {
+    if (!pix_ && attr_.map_state != IsUnmapped) {
         pix_ = XCompositeNameWindowPixmap(xdpy_, win_);
         Log::debug("    => Pixmap <= 0x%x\n", (unsigned) pix_);
         update_tfp = true;
     }
-    else if (pix_ && attr_.map_state == 0) {
+    else if (pix_ && attr_.map_state == IsUnmapped) {
         Log::debug("    => Destroying Pixmap 0x%x\n", (unsigned) pix_);
         pix_to_free = pix_;
         pix_ = None;
@@ -85,11 +85,11 @@ 
 
     Log::debug("    => Damage State <= 0x%x\n", (unsigned) damage_);
     /* Update damage object */
-    if (!damage_ && attr_.map_state != 0) {
+    if (!damage_ && attr_.map_state != IsUnmapped) {
         damage_ = XDamageCreate(xdpy_, win_, XDamageReportNonEmpty);
         Log::debug("    => Damage <= 0x%x\n", (unsigned) damage_);
     }
-    else if (damage_ && attr_.map_state == 0) {
+    else if (damage_ && attr_.map_state == IsUnmapped) {
         Log::debug("    => Destroying damage 0x%x\n", (unsigned) damage_);
         XDamageDestroy(xdpy_, damage_);
         damage_ = None;