[vlmc-devel] VlmcLogger: Fix build for Qt5

Hugo Beauzée-Luyssen git at videolan.org
Sat Feb 8 23:24:53 CET 2014


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sun Feb  9 00:24:00 2014 +0200| [4e5e3afc60add5d139dc562f36c868802484af08] | committer: Hugo Beauzée-Luyssen

VlmcLogger: Fix build for Qt5

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=4e5e3afc60add5d139dc562f36c868802484af08
---

 src/Tools/VlmcLogger.cpp |   11 +++++++++++
 src/Tools/VlmcLogger.h   |    4 ++++
 2 files changed, 15 insertions(+)

diff --git a/src/Tools/VlmcLogger.cpp b/src/Tools/VlmcLogger.cpp
index dd7e3d8..5fa14dc 100644
--- a/src/Tools/VlmcLogger.cpp
+++ b/src/Tools/VlmcLogger.cpp
@@ -90,7 +90,11 @@ VlmcLogger::~VlmcLogger()
 void
 VlmcLogger::setup()
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    qInstallMessageHandler( VlmcLogger::vlmcMessageHandler );
+#else
     qInstallMsgHandler( VlmcLogger::vlmcMessageHandler );
+#endif
 }
 
 void
@@ -117,8 +121,15 @@ VlmcLogger::writeToFile(const char *msg)
 }
 
 void
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+VlmcLogger::vlmcMessageHandler( QtMsgType type, const QMessageLogContext&, const QString& str )
+{
+    const QByteArray byteArray = str.toLocal8Bit();
+    const char* msg = byteArray.constData();
+#else
 VlmcLogger::vlmcMessageHandler( QtMsgType type, const char* msg )
 {
+#endif
     //FIXME: This is ok as long as we guarantee no log message will arrive after
     // we uninstall the hook
 
diff --git a/src/Tools/VlmcLogger.h b/src/Tools/VlmcLogger.h
index cd8dcba..56ac2c0 100644
--- a/src/Tools/VlmcLogger.h
+++ b/src/Tools/VlmcLogger.h
@@ -47,7 +47,11 @@ class   VlmcLogger : public QObject, public Singleton<VlmcLogger>
             Quiet = QtCriticalMsg
         };
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+        static void     vlmcMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& str );
+#else
         static void     vlmcMessageHandler( QtMsgType type, const char* msg );
+#endif
         void            setup();
     private:
         VlmcLogger();



More information about the Vlmc-devel mailing list