Skip to content
Browse files

Display Qt warnings and errors in Console and Issues views

This change intercepts any debug messages, warnings and error messages
sent through the Qt library in order to display them in the Console and
Issues views.

It may be confusing because some of these messages may not be anything
the user can do something about, but this seems like the only way to get
script errors that happen while calling functions connected to signals
to be visible. We'll see if there's any messages that should rather be
filtered out.
  • Loading branch information...
bjorn committed Oct 23, 2019
1 parent f0ec7f6 commit 4d1f3eb23b4759383d3b35e9df86ef33f4ac1881
Showing with 27 additions and 0 deletions.
  1. +27 −0 src/tiled/main.cpp
@@ -23,6 +23,7 @@
#include "commandlineparser.h"
#include "exporthelper.h"
#include "languagemanager.h"
#include "logginginterface.h"
#include "mainwindow.h"
#include "mapdocument.h"
#include "mapformat.h"
@@ -98,6 +99,30 @@ class CommandLineHandler : public CommandLineParser

static const QtMessageHandler QT_DEFAULT_MESSAGE_HANDLER = qInstallMessageHandler(0);

void messagesToConsole(QtMsgType type, const QMessageLogContext &context, const QString &msg)
QString txt;
switch (type) {
case QtFatalMsg:
// program will quit so no point routing to the Console window
case QtInfoMsg:
case QtDebugMsg:
INFO(qFormatLogMessage(type, context, msg));
case QtWarningMsg:
WARNING(qFormatLogMessage(type, context, msg));
case QtCriticalMsg:
ERROR(qFormatLogMessage(type, context, msg));

(*QT_DEFAULT_MESSAGE_HANDLER)(type, context, msg);

* Used during file export, attempt to determine the output file format
* from the command line parameters.
@@ -314,6 +339,8 @@ int main(int argc, char *argv[])



// Enable support for highres images (added in Qt 5.1, but off by default)

0 comments on commit 4d1f3eb

Please sign in to comment.
You can’t perform that action at this time.