Fix QT_DEPRECATED_SINCE evaluation
authorBradley T. Hughes <bradley.hughes@nokia.com>
Mon, 5 Dec 2011 12:05:44 +0000 (13:05 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 5 Dec 2011 22:03:16 +0000 (23:03 +0100)
QT_DEPRECATED is defined by default by the logic in qglobal.h, but
QT_DEPRECATED_SINCE is evaluated before that definition, making
QT_DEPRECATED_SINCE evaluate to 0, disabling all deprecated code (even
though it shouldn't be disabled).

Fix this by moving the QT_DEPRECATED_SINCE evaluation to after the
evaluation of QT_NO_DEPRECATED and/or definition of QT_DEPRECATED, to
ensure that QT_DEPRECATED_SINCE works as expected.

Change-Id: I57d9f6a3e1859b0057fd4f37bcf2d2cc3dfba230
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/corelib/global/qglobal.h

index aa6a1e8..e22d666 100644 (file)
 */
 #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
 
-#ifndef QT_DISABLE_DEPRECATED_BEFORE
-// ### Qt5: remember to change that to 5 when we reach feature freeze
-#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 9, 0)
-#endif
-
-/*
-    QT_DEPRECATED_SINCE(major, minor) evaluates as true if the Qt version is greater than
-    the deprecation point specified.
-
-    Use it to specify from which version of Qt a function or class has been deprecated
-
-    Example:
-        #if QT_DEPRECATED_SINCE(5,1)
-            QT_DEPRECATED void deprecatedFunction(); //function deprecated since Qt 5.1
-        #endif
-
-*/
-#ifdef QT_DEPRECATED
-#define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_BEFORE)
-#else
-#define QT_DEPRECATED_SINCE(major, minor) 0
-#endif
-
 #define QT_PACKAGEDATE_STR "YYYY-MM-DD"
 
 #define QT_PACKAGE_TAG ""
@@ -1014,6 +991,29 @@ redefine to built-in booleans to make autotests work properly */
 #  define QT_DEPRECATED_CONSTRUCTOR
 #endif
 
+#ifndef QT_DISABLE_DEPRECATED_BEFORE
+// ### Qt5: remember to change that to 5 when we reach feature freeze
+#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 9, 0)
+#endif
+
+/*
+    QT_DEPRECATED_SINCE(major, minor) evaluates as true if the Qt version is greater than
+    the deprecation point specified.
+
+    Use it to specify from which version of Qt a function or class has been deprecated
+
+    Example:
+        #if QT_DEPRECATED_SINCE(5,1)
+            QT_DEPRECATED void deprecatedFunction(); //function deprecated since Qt 5.1
+        #endif
+
+*/
+#ifdef QT_DEPRECATED
+#define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_BEFORE)
+#else
+#define QT_DEPRECATED_SINCE(major, minor) 0
+#endif
+
 /* moc compats (signals/slots) */
 #ifndef QT_MOC_COMPAT
 #  define QT_MOC_COMPAT