From a3db5ec5f7ec833f47df70bf010fe9cbdffae38e Mon Sep 17 00:00:00 2001 From: Mariano Lizarraga Date: Fri, 28 Jan 2011 11:31:46 -0600 Subject: [PATCH] Added a qDebug() message handler for windows installs that have no debug helpers. Hunting bug in Mode change in UASView --- qgroundcontrol.pri | 3 ++- src/Core.cc | 3 +++ src/main.cc | 21 +++++++++++++++++++++ src/uas/UAS.cc | 2 ++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index f846c60..576108a 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -380,7 +380,8 @@ win32-g++ { message(Building for Windows Platform (32bit)) # Special settings for debug - #CONFIG += CONSOLE + CONFIG += CONSOLE + OUTPUT += CONSOLE INCLUDEPATH += $$BASEDIR/lib/sdl/include \ $$BASEDIR/lib/opal/include #\ #\ diff --git a/src/Core.cc b/src/Core.cc index d584698..38a37b9 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -65,8 +65,11 @@ This file is part of the QGROUNDCONTROL project * @param argv The string array of parameters **/ + Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) { + + // Set application name this->setApplicationName(QGC_APPLICATION_NAME); this->setApplicationVersion(QGC_APPLICATION_VERSION); diff --git a/src/main.cc b/src/main.cc index a27a8d3..ba6d1af 100644 --- a/src/main.cc +++ b/src/main.cc @@ -39,6 +39,21 @@ This file is part of the QGROUNDCONTROL project #undef main #endif + +// Install a message handler so you do not need +// the MSFT debug tools installed to se +// qDebug(), qWarning(), qCritical and qAbort +#ifdef Q_OS_WIN +void msgHandler( QtMsgType type, const char* msg ) +{ + const char symbols[] = { 'I', 'E', '!', 'X' }; + QString output = QString("[%1] %2").arg( symbols[type] ).arg( msg ); + std::cerr << output.toStdString() << std::endl; + if( type == QtFatalMsg ) abort(); +} + +#endif + /** * @brief Starts the application * @@ -46,9 +61,15 @@ This file is part of the QGROUNDCONTROL project * @param argv Commandline arguments * @return exit code, 0 for normal exit and !=0 for error cases */ + int main(int argc, char *argv[]) { +// install the message handler +#ifdef Q_OS_WIN + qInstallMsgHandler( msgHandler ); +#endif + Core core(argc, argv); return core.exec(); } diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index dde06f5..3d8c184 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -264,6 +264,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) stateAudio = " changed status to " + uasState; } + qDebug() << "Remote Mode: " << state.mode; + qDebug() << "Loclal Mode: " << this->mode; if (this->mode != static_cast(state.mode)) { modechanged = true;