diff --git a/src/main.cc b/src/main.cc index 1b0e8846a8ebf0a2ca3123528a0c922d7f295072..76b278dca4f111664b7e5a2fc442a46d0e0d3331 100644 --- a/src/main.cc +++ b/src/main.cc @@ -36,6 +36,10 @@ This file is part of the QGROUNDCONTROL project #include "TCPLink.h" #ifdef QT_DEBUG #include "AutoTest.h" +#include "CmdLineOptParser.h" +#ifdef Q_OS_WIN +#include +#endif #endif /* SDL does ugly things to main() */ @@ -44,10 +48,10 @@ This file is part of the QGROUNDCONTROL project #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 + +/// @brief Message handler which is installed using qInstallMsgHandler so you do not need +/// the MSFT debug tools installed to see qDebug(), qWarning(), qCritical and qAbort void msgHandler( QtMsgType type, const char* msg ) { const char symbols[] = { 'I', 'E', '!', 'X' }; @@ -56,6 +60,17 @@ void msgHandler( QtMsgType type, const char* msg ) if( type == QtFatalMsg ) abort(); } +/// @brief CRT Report Hook installed using _CrtSetReportHook. We install this hook when +/// we don't want asserts to pop a dialog on windows. +int WindowsCrtReportHook(int reportType, char* message, int* returnValue) +{ + Q_UNUSED(reportType); + + std::cerr << message << std::endl; // Output message to stderr + *returnValue = 0; // Don't break into debugger + return true; // We handled this fully ourselves +} + #endif /** @@ -81,13 +96,27 @@ int main(int argc, char *argv[]) qRegisterMetaType(); #ifdef QT_DEBUG - if (argc > 1 && QString(argv[1]).compare("--unittest", Qt::CaseInsensitive) == 0) { - // Strip off extra command line args so QTest doesn't complain - for (int i=1; i