Fixed regression in tst_qscreen.
authorSamuel Rødal <samuel.rodal@nokia.com>
Tue, 22 Nov 2011 16:16:11 +0000 (17:16 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 23 Nov 2011 21:23:55 +0000 (22:23 +0100)
The ScreenOrientation enum was changed so that the values are power of
twos, angleBetween() needed to be fixed in order to reflect this.

Task-number: QTBUG-22554
Change-Id: Ia45dd6643b40b14204abf967b00c0d04834736a3
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/gui/kernel/qscreen.cpp
tests/auto/gui/kernel/qscreen/qscreen.pro

index 8c25bea..7d83ceb 100644 (file)
@@ -335,6 +335,20 @@ Qt::ScreenOrientation QScreen::currentOrientation() const
     return d->platformScreen->currentOrientation();
 }
 
+// i must be power of two
+static int log2(uint i)
+{
+    if (i == 0)
+        return -1;
+
+    int result = 0;
+    while (!(i & 1)) {
+        ++result;
+        i >>= 1;
+    }
+    return result;
+}
+
 /*!
     Convenience function to compute the angle of rotation to get from
     rotation \a a to rotation \a b.
@@ -346,7 +360,10 @@ int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
     if (a == Qt::UnknownOrientation || b == Qt::UnknownOrientation || a == b)
         return 0;
 
-    int delta = int(b) - int(a);
+    int ia = log2(uint(a));
+    int ib = log2(uint(b));
+
+    int delta = ia - ib;
 
     if (delta < 0)
         delta = delta + 4;
index 4ed8eef..b631f4c 100644 (file)
@@ -4,5 +4,3 @@ TARGET = tst_qscreen
 QT += core-private gui-private testlib
 
 SOURCES  += tst_qscreen.cpp
-
-CONFIG += insignificant_test # QTBUG-22554