Avoid race condition
authorPaul Olav Tvete <paul.tvete@nokia.com>
Tue, 13 Mar 2012 11:33:34 +0000 (12:33 +0100)
committerSamuel Rødal <samuel.rodal@nokia.com>
Tue, 13 Mar 2012 15:07:07 +0000 (16:07 +0100)
m_damaged may be set from a different thread while updateTexture() is
being executed. This change does not eliminate the race completely, but
will fail by creating the same texture twice instead of keeping an old,
invalid one.

Change-Id: Ic34d6df1699bd3d94fde3590343e4a524c9de6a2
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/compositor/compositor_api/waylandsurfaceitem.cpp

index 7a19244..704cba0 100644 (file)
@@ -324,6 +324,7 @@ private:
 void WaylandSurfaceItem::updateTexture()
 {
     if (m_damaged) {
+        m_damaged = false;
         QSGTexture *oldTexture = m_texture;
         if (m_surface->type() == WaylandSurface::Texture) {
             QOpenGLContext *context = QOpenGLContext::currentContext();
@@ -337,7 +338,6 @@ void WaylandSurfaceItem::updateTexture()
         }
 
         delete oldTexture;
-        m_damaged = false;
     }
 
     if (m_provider) {