From: Albert Astals Cid Date: Fri, 6 Feb 2015 09:40:03 +0000 (+0100) Subject: Fix regression where QQuickScreenAttached overwrites QScreen values X-Git-Tag: v5.5.90+alpha1~3^2~242^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c678e09c997ee96563404a28820c5068679e633;p=platform%2Fupstream%2Fqtdeclarative.git Fix regression where QQuickScreenAttached overwrites QScreen values 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 --- diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp index 8ac5a1e..c4d1407 100644 --- a/src/quick/items/qquickscreen.cpp +++ b/src/quick/items/qquickscreen.cpp @@ -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(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(); diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h index 257b18c..a36641c 100644 --- a/src/quick/items/qquickscreen_p.h +++ b/src/quick/items/qquickscreen_p.h @@ -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