Fix adding and removing of windows to their screen
authorThomas McGuire <thomas.mcguire@kdab.com>
Mon, 2 Apr 2012 10:04:53 +0000 (12:04 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 3 Apr 2012 10:45:46 +0000 (12:45 +0200)
Change-Id: I5e0edf1515db60689c86b16b978863ae9e49bfdb
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
src/plugins/platforms/qnx/qqnxscreen.cpp
src/plugins/platforms/qnx/qqnxwindow.cpp

index 7ae1988..7ddef32 100644 (file)
@@ -223,8 +223,9 @@ void QQnxScreen::removeWindow(QQnxWindow *window)
     qDebug() << Q_FUNC_INFO << "window =" << window;
 #endif
 
-    m_childWindows.removeAll(window);
-    updateHierarchy();
+    const int numWindowsRemoved = m_childWindows.removeAll(window);
+    if (numWindowsRemoved > 0)
+        updateHierarchy();
 }
 
 void QQnxScreen::raiseWindow(QQnxWindow *window)
index 66eb1cf..4ca084f 100644 (file)
@@ -123,9 +123,6 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context)
 
     setScreen(static_cast<QQnxScreen *>(window->screen()->handle()));
 
-    // Add the window to the root of the hierarchy
-    m_screen->addWindow(this);
-
     // Add window to plugin's window mapper
     QQnxIntegration::addWindow(m_window, window);
 }
@@ -415,11 +412,9 @@ void QQnxWindow::setScreen(QQnxScreen *platformScreen)
     if (m_screen == platformScreen)
         return;
 
-    if (m_screen && m_screen->findWindow(m_window)) {
+    if (m_screen)
         m_screen->removeWindow(this);
-        platformScreen->addWindow(this);
-    }
-
+    platformScreen->addWindow(this);
     m_screen = platformScreen;
 
     // Move window to proper screen/display