Logging: Mark deprecated API with QT_DEPRECATED
authorKai Koehne <kai.koehne@digia.com>
Tue, 18 Sep 2012 07:57:51 +0000 (09:57 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 16 Oct 2012 13:29:15 +0000 (15:29 +0200)
Still use it in qtestlib though because using qInstallMessageHandler
here would break all tests (still) using qInstallMsgHandler - Qt always
uses the new message handler if there's one, ignoring any message handler
installed through deprecated API.

Change-Id: I6fefefb315a2421425d2b7787e367fd348a33d83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/global/qlogging.cpp
src/corelib/global/qlogging.h
src/testlib/qtestlog.cpp

index 13bbdbe..e4ff7ee 100644 (file)
@@ -780,6 +780,12 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont
     return message;
 }
 
+#if !QT_DEPRECATED_SINCE(5, 0)
+// make sure they're defined to be exported
+typedef void (*QtMsgHandler)(QtMsgType, const char *);
+Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
+#endif
+
 static QtMsgHandler msgHandler = 0;                // pointer to debug handler (without context)
 static QtMessageHandler messageHandler = 0;         // pointer to debug handler (with context)
 
index 0c92e71..4a4eb26 100644 (file)
@@ -161,9 +161,10 @@ Q_CORE_EXPORT void qt_message_output(QtMsgType, const QMessageLogContext &contex
 Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
 Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
 
-// deprecated. Use qInstallMessageHandler instead!
+#if QT_DEPRECATED_SINCE(5, 0)// deprecated. Use qInstallMessageHandler instead!
 typedef void (*QtMsgHandler)(QtMsgType, const char *);
-Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
+Q_CORE_EXPORT QT_DEPRECATED QtMsgHandler qInstallMsgHandler(QtMsgHandler);
+#endif
 
 typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &);
 Q_CORE_EXPORT QtMessageHandler qInstallMessageHandler(QtMessageHandler);
index 7cd83c8..c56a002 100644 (file)
@@ -76,6 +76,14 @@ static void saveCoverageTool(const char * appname, bool testfailed, bool install
 #endif
 }
 
+//
+// declare deprecated API from qlogging.h locally
+// (we can't use qInstallMessageHandler because it would break
+// tests that (still) rely on qInstallMsgHandler.)
+//
+typedef void (*QtMsgHandler)(QtMsgType, const char *);
+Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
+
 namespace QTest {
 
     int fails = 0;