VirtualBox

Changeset 57769 in vbox for trunk/src


Ignore:
Timestamp:
Sep 15, 2015 4:43:21 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Main.cpp cleanup/rework bit-by-bit (step 9).

File:
1 edited

Legend:

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

    r57768 r57769  
    325325    int iResultCode = 1;
    326326
    327 #ifdef Q_WS_X11
    328     /* Make sure multi-threaded environment is safe: */
    329     if (!MakeSureMultiThreadingIsSafe())
    330         return iResultCode;
    331 #endif /* Q_WS_X11 */
    332 
    333327    /* Simulate try-catch block: */
    334328    do
    335329    {
    336 #ifdef Q_WS_MAC
    337         /* Prevent check in AppKit: */
    338         PreventCheckInAppKit();
    339 #endif /* Q_WS_MAC */
    340 
    341330        /* Console help preprocessing: */
    342331        bool fHelpShown = false;
     
    359348        }
    360349
    361 #if defined(Q_WS_X11) && defined(RT_OS_LINUX) && defined(DEBUG)
    362         /* Install signal handler to backtrace the call stack: */
    363         InstallSignalHandler();
    364 #endif /* Q_WS_X11 && RT_OS_LINUX && DEBUG */
    365 
    366350#ifdef VBOX_WITH_HARDENING
    367351        /* Make sure the image verification code works: */
     
    370354
    371355#ifdef Q_WS_MAC
    372         /* Apply font fixes: */
     356        /* Prevent check in AppKit: */
     357        PreventCheckInAppKit();
     358
     359        /* Apply font fixes (before QApplication get created and instantiated font-hints): */
    373360        switch (VBoxGlobal::osRelease())
    374361        {
     
    377364            default: break;
    378365        }
     366
    379367# ifdef QT_MAC_USE_COCOA
    380368        /* Instantiate own NSApplication before QApplication do it for us: */
     
    383371#endif /* Q_WS_MAC */
    384372
     373#ifdef Q_WS_X11
     374        /* Make sure multi-threaded environment is safe: */
     375        if (!MakeSureMultiThreadingIsSafe())
     376            break;
     377
     378# if defined(RT_OS_LINUX) && defined(DEBUG)
     379        /* Install signal handler to backtrace the call stack: */
     380        InstallSignalHandler();
     381# endif /* RT_OS_LINUX && DEBUG */
     382#endif /* Q_WS_X11 */
     383
    385384        /* Install Qt console message handler: */
    386385        qInstallMsgHandler(QtMessageOutput);
     
    388387        /* Create application: */
    389388        QApplication a(argc, argv);
    390 
    391 #ifdef Q_WS_X11
    392         /* Make all widget native.
    393          * We did it to avoid various Qt crashes while testing widget attributes or acquiring winIds.
    394          * Yes, we aware of note that alien widgets faster to draw but the only widget we need to be fast
    395          * is viewport of VM which was always native since we are using his id for 3D service needs. */
    396         a.setAttribute(Qt::AA_NativeWindows);
    397 #endif /* Q_WS_X11 */
    398 
    399 #ifdef Q_WS_MAC
    400 # ifdef VBOX_GUI_WITH_HIDPI
    401         /* Enable HiDPI icons.
    402          * For this we require a patched version of Qt 4.x with
    403          * the changes from https://codereview.qt-project.org/#change,54636 applied. */
    404         a.setAttribute(Qt::AA_UseHighDpiPixmaps);
    405 # endif /* VBOX_GUI_WITH_HIDPI */
    406 #endif /* Q_WS_MAC */
    407 
    408 #ifdef Q_OS_SOLARIS
    409         /* Use plastique look&feel for Solaris instead of the default motif (Qt 4.7.x): */
    410         QApplication::setStyle(new QPlastiqueStyle);
    411 #endif /* Q_OS_SOLARIS */
    412 
    413 #ifdef Q_WS_X11
    414 # ifndef Q_OS_SOLARIS
    415         /* Apply font fixes: */
    416         QFontDatabase fontDataBase;
    417         QString currentFamily(QApplication::font().family());
    418         bool isCurrentScaleable = fontDataBase.isScalable(currentFamily);
    419         QString subFamily(QFont::substitute(currentFamily));
    420         bool isSubScaleable = fontDataBase.isScalable(subFamily);
    421         if (isCurrentScaleable && !isSubScaleable)
    422             QFont::removeSubstitution(currentFamily);
    423 # endif /* !Q_OS_SOLARIS */
    424 #endif /* Q_WS_X11 */
    425389
    426390#ifdef Q_WS_WIN
     
    435399
    436400#ifdef Q_WS_MAC
     401# ifdef VBOX_GUI_WITH_HIDPI
     402        /* Enable HiDPI icons.
     403         * For this we require a patched version of Qt 4.x with
     404         * the changes from https://codereview.qt-project.org/#change,54636 applied. */
     405        a.setAttribute(Qt::AA_UseHighDpiPixmaps);
     406# endif /* VBOX_GUI_WITH_HIDPI */
     407
    437408        /* Disable menu icons on MacOS X host: */
    438409        ::darwinDisableIconsInMenus();
     
    440411
    441412#ifdef Q_WS_X11
     413        /* Make all widget native.
     414         * We did it to avoid various Qt crashes while testing widget attributes or acquiring winIds.
     415         * Yes, we aware of note that alien widgets faster to draw but the only widget we need to be fast
     416         * is viewport of VM which was always native since we are using his id for 3D service needs. */
     417        a.setAttribute(Qt::AA_NativeWindows);
     418
     419# ifdef Q_OS_SOLARIS
     420        /* Use plastique look&feel for Solaris instead of the default motif (Qt 4.7.x): */
     421        QApplication::setStyle(new QPlastiqueStyle);
     422# endif /* Q_OS_SOLARIS */
     423
     424# ifndef Q_OS_SOLARIS
     425        /* Apply font fixes (after QApplication get created and instantiated font-family): */
     426        QFontDatabase fontDataBase;
     427        QString currentFamily(QApplication::font().family());
     428        bool isCurrentScaleable = fontDataBase.isScalable(currentFamily);
     429        QString subFamily(QFont::substitute(currentFamily));
     430        bool isSubScaleable = fontDataBase.isScalable(subFamily);
     431        if (isCurrentScaleable && !isSubScaleable)
     432            QFont::removeSubstitution(currentFamily);
     433# endif /* !Q_OS_SOLARIS */
     434
    442435        /* Qt version check (major.minor are sensitive, fix number is ignored): */
    443436        if (VBoxGlobal::qtRTVersion() < (VBoxGlobal::qtCTVersion() & 0xFFFF00))
     
    648641{
    649642# ifdef Q_WS_MAC
     643    /* Prevent check in AppKit: */
    650644    PreventCheckInAppKit();
    651645# endif /* Q_WS_MAC */
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