diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-02-05 11:26:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-05 18:17:56 +0100 |
commit | 3466bcd8fb345f4ed7d696354bbd8bcedaea15a1 (patch) | |
tree | 2d3f78048fd0203b8ca96972be58484a08eeae5b /tools/qmlplugindump/main.cpp | |
parent | 4dfe58d27ced74c0e28c1764ac036d7ec27f14c9 (diff) |
Force QML engine debug output to stderr in qmlplugindump
In this case the debug output is actually meant to be read by the user.
Logging it to some system facility, as on BlackBerry doesn't help. To
fix that a message handler that redirects all debug output to stderr
is installed.
Task-number: QTBUG-36378
Change-Id: I16dbca8bc4d07e0aabc2b41ce93b56bd679fa166
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Diffstat (limited to 'tools/qmlplugindump/main.cpp')
-rw-r--r-- | tools/qmlplugindump/main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index d53005109e..e53d8c2800 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -684,8 +684,26 @@ void printUsage(const QString &appName) appName)) << std::endl; } +inline std::wostream &operator<<(std::wostream &str, const QString &s) +{ +#ifdef Q_OS_WIN + str << reinterpret_cast<const wchar_t *>(s.utf16()); +#else + str << s.toStdWString(); +#endif + return str; +} + +void printDebugMessage(QtMsgType, const QMessageLogContext &, const QString &msg) +{ + std::wcerr << msg << std::endl; + // In case of QtFatalMsg the calling code will abort() when appropriate. +} + int main(int argc, char *argv[]) { + // The default message handler might not print to console on some systems. Enforce this. + qInstallMessageHandler(printDebugMessage); #ifdef Q_OS_UNIX // qmldump may crash, but we don't want any crash handlers to pop up // therefore we intercept the segfault and just exit() ourselves |