Blob Blame History Raw
diff -rupN qtbase-opensource-src-5.5.0/src/gui/kernel/qplatformintegration.cpp qtbase-opensource-src-5.5.0-new/src/gui/kernel/qplatformintegration.cpp
--- qtbase-opensource-src-5.5.0/src/gui/kernel/qplatformintegration.cpp	2015-06-29 22:04:53.000000000 +0200
+++ qtbase-opensource-src-5.5.0-new/src/gui/kernel/qplatformintegration.cpp	2015-07-12 10:24:17.195000304 +0200
@@ -456,6 +456,14 @@ void QPlatformIntegration::screenAdded(Q
     } else {
         QGuiApplicationPrivate::screen_list.append(screen);
     }
+
+    // All screens might have been removed before a new one is added, so
+    // iterate over the toplevel windows and set their screen to the current
+    // primary screen if the window has no screen set
+    foreach (QWindow *window, QGuiApplication::topLevelWindows()) {
+        if (window->screen() == 0)
+            window->setScreen(QGuiApplicationPrivate::screen_list.at(0));
+    }
     emit qGuiApp->screenAdded(screen);
 }
 
diff -rupN qtbase-opensource-src-5.5.0/src/gui/kernel/qwindow.cpp qtbase-opensource-src-5.5.0-new/src/gui/kernel/qwindow.cpp
--- qtbase-opensource-src-5.5.0/src/gui/kernel/qwindow.cpp	2015-06-29 22:04:52.000000000 +0200
+++ qtbase-opensource-src-5.5.0-new/src/gui/kernel/qwindow.cpp	2015-07-12 11:51:18.832889497 +0200
@@ -372,15 +372,14 @@ void QWindowPrivate::setTopLevelScreen(Q
         return;
     }
     if (newScreen != topLevelScreen) {
-        const bool shouldRecreate = recreate && windowRecreationRequired(newScreen);
-        const bool shouldShow = visibilityOnDestroy && !topLevelScreen;
+        const bool shouldRecreate = recreate/* && windowRecreationRequired(newScreen)*/;
         if (shouldRecreate && platformWindow)
             q->destroy();
         connectToScreen(newScreen);
-        if (shouldShow)
-            q->setVisible(true);
-        else if (newScreen && shouldRecreate)
+        if (newScreen && shouldRecreate) {
             create(true);
+            q->setVisible(visibilityOnDestroy);
+        }
         emitScreenChangedRecursion(newScreen);
     }
 }