Fix regression where QQuickScreenAttached overwrites QScreen values
authorAlbert Astals Cid <albert.astals@canonical.com>
Fri, 6 Feb 2015 09:40:03 +0000 (10:40 +0100)
committerAlbert Astals Cid <albert.astals@canonical.com>
Fri, 6 Feb 2015 10:08:36 +0000 (10:08 +0000)
Up to Qt 5.3 it was fine setting the orientationUpdateMask in
QScreen in C++, with 5.4 that value is always discarded and overwrote
with 0, this change makes it possible to still set the orientationUpdateMask
value in C++ and not have it overwritten unless specifically changed from QML

Change-Id: I134290ce91be8b91df4e9e8e71120753813f48d7
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
src/quick/items/qquickscreen.cpp
src/quick/items/qquickscreen_p.h

index 8ac5a1e..c4d1407 100644 (file)
@@ -197,7 +197,7 @@ QT_BEGIN_NAMESPACE
     This contains the update mask for the orientation. Screen::orientation
     only emits changes for the screen orientations matching this mask.
 
-    The default, \c 0, means Screen::orientation never updates.
+    By default it is set to the value of the QScreen that the window uses.
 */
 
 QQuickScreenAttached::QQuickScreenAttached(QObject* attachee)
@@ -205,6 +205,7 @@ QQuickScreenAttached::QQuickScreenAttached(QObject* attachee)
     , m_screen(NULL)
     , m_window(NULL)
     , m_updateMask(0)
+    , m_updateMaskSet(false)
 {
     m_attachee = qobject_cast<QQuickItem*>(attachee);
 
@@ -297,6 +298,7 @@ Qt::ScreenOrientations QQuickScreenAttached::orientationUpdateMask() const
 
 void QQuickScreenAttached::setOrientationUpdateMask(Qt::ScreenOrientations mask)
 {
+    m_updateMaskSet = true;
     if (m_updateMask == mask)
         return;
 
@@ -338,7 +340,12 @@ void QQuickScreenAttached::screenChanged(QScreen *screen)
         if (!screen)
             return; //Don't bother emitting signals, because the new values are garbage anyways
 
-        screen->setOrientationUpdateMask(m_updateMask);
+        if (m_updateMaskSet) {
+            screen->setOrientationUpdateMask(m_updateMask);
+        } else if (m_updateMask != screen->orientationUpdateMask()) {
+            m_updateMask = screen->orientationUpdateMask();
+            emit orientationUpdateMaskChanged();
+        }
 
         if (!oldScreen || screen->size() != oldScreen->size()) {
             emit widthChanged();
index 257b18c..a36641c 100644 (file)
@@ -106,6 +106,7 @@ private:
     QQuickWindow* m_window;
     QQuickItem* m_attachee;
     Qt::ScreenOrientations m_updateMask;
+    bool m_updateMaskSet;
 };
 
 class Q_AUTOTEST_EXPORT QQuickScreen : public QObject