VirtualBox

Changeset 58848 in vbox


Ignore:
Timestamp:
Nov 25, 2015 12:52:04 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Qt5 migration (part 1): QtMessageOutput stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r58328 r58848  
    226226#endif /* Q_WS_X11 */
    227227
    228 /** Qt message handler, function that prints out
    229   * debug messages, warnings, critical and fatal error messages.
    230   * @param type describes the type of message sent to a message handler.
    231   * @param pMsg holds the pointer to the message body. */
     228#if QT_VERSION >= 0x050000
     229/** Qt5 message handler, function that prints out
     230  * debug, warning, critical, fatal and system error messages.
     231  * @param  type        Holds the type of the message.
     232  * @param  context     Holds the message context.
     233  * @param  strMessage  Holds the message body. */
     234static void QtMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &strMessage)
     235{
     236    NOREF(context);
     237# ifndef Q_WS_X11
     238    NOREF(strMessage);
     239# endif /* !Q_WS_X11 */
     240    switch (type)
     241    {
     242        case QtDebugMsg:
     243            Log(("Qt DEBUG: %s\n", strMessage.toUtf8().constData()));
     244            break;
     245        case QtWarningMsg:
     246            Log(("Qt WARNING: %s\n", strMessage.toUtf8().constData()));
     247# ifdef Q_WS_X11
     248            /* Needed for instance for the message ``cannot connect to X server'': */
     249            RTStrmPrintf(g_pStdErr, "Qt WARNING: %s\n", strMessage.toUtf8().constData());
     250# endif /* Q_WS_X11 */
     251            break;
     252        case QtCriticalMsg:
     253            Log(("Qt CRITICAL: %s\n", strMessage.toUtf8().constData()));
     254# ifdef Q_WS_X11
     255            /* Needed for instance for the message ``cannot connect to X server'': */
     256            RTStrmPrintf(g_pStdErr, "Qt CRITICAL: %s\n", strMessage.toUtf8().constData());
     257# endif /* Q_WS_X11 */
     258            break;
     259        case QtFatalMsg:
     260            Log(("Qt FATAL: %s\n", strMessage.toUtf8().constData()));
     261# ifdef Q_WS_X11
     262            /* Needed for instance for the message ``cannot connect to X server'': */
     263            RTStrmPrintf(g_pStdErr, "Qt FATAL: %s\n", strMessage.toUtf8().constData());
     264# endif /* Q_WS_X11 */
     265    }
     266}
     267#else /* QT_VERSION < 0x050000 */
     268/** Qt4 message handler, function that prints out
     269  * debug, warning, critical, fatal and system error messages.
     270  * @param  type  Holds the type of the message.
     271  * @param  pMsg  Holds the the message body. */
    232272static void QtMessageOutput(QtMsgType type, const char *pMsg)
    233273{
    234 #ifndef Q_WS_X11
     274# ifndef Q_WS_X11
    235275    NOREF(pMsg);
    236 #endif /* !Q_WS_X11 */
     276# endif /* !Q_WS_X11 */
    237277    switch (type)
    238278    {
     
    242282        case QtWarningMsg:
    243283            Log(("Qt WARNING: %s\n", pMsg));
    244 #ifdef Q_WS_X11
     284# ifdef Q_WS_X11
    245285            /* Needed for instance for the message ``cannot connect to X server'': */
    246286            RTStrmPrintf(g_pStdErr, "Qt WARNING: %s\n", pMsg);
    247 #endif /* Q_WS_X11 */
     287# endif /* Q_WS_X11 */
    248288            break;
    249289        case QtCriticalMsg:
    250290            Log(("Qt CRITICAL: %s\n", pMsg));
    251 #ifdef Q_WS_X11
     291# ifdef Q_WS_X11
    252292            /* Needed for instance for the message ``cannot connect to X server'': */
    253293            RTStrmPrintf(g_pStdErr, "Qt CRITICAL: %s\n", pMsg);
    254 #endif /* Q_WS_X11 */
     294# endif /* Q_WS_X11 */
    255295            break;
    256296        case QtFatalMsg:
    257297            Log(("Qt FATAL: %s\n", pMsg));
    258 #ifdef Q_WS_X11
     298# ifdef Q_WS_X11
    259299            /* Needed for instance for the message ``cannot connect to X server'': */
    260300            RTStrmPrintf(g_pStdErr, "Qt FATAL: %s\n", pMsg);
    261 #endif /* Q_WS_X11 */
     301# endif /* Q_WS_X11 */
    262302    }
    263303}
     304#endif /* QT_VERSION < 0x050000 */
    264305
    265306/** Shows all available command line parameters. */
     
    389430#endif /* Q_WS_X11 */
    390431
     432#if QT_VERSION >= 0x050000
     433        /* Install Qt console message handler: */
     434        qInstallMessageHandler(QtMessageOutput);
     435#else /* QT_VERSION < 0x050000 */
    391436        /* Install Qt console message handler: */
    392437        qInstallMsgHandler(QtMessageOutput);
     438#endif /* QT_VERSION < 0x050000 */
    393439
    394440        /* Create application: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette