VirtualBox

Changeset 45448 in vbox


Ignore:
Timestamp:
Apr 10, 2013 7:59:40 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84880
Message:

FE/Qt: Main.cpp cleanup (part 3).

File:
1 edited

Legend:

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

    r45439 r45448  
    304304    LogFlowFuncEnter();
    305305
    306 # ifdef RT_OS_DARWIN
    307     ShutUpAppKit();
    308 # endif /* RT_OS_DARWIN */
    309 
    310     /* Console help preprocessing: */
    311     for (int i=0; i<argc; i++)
    312         if (   !strcmp(argv[i], "-h")
    313             || !strcmp(argv[i], "-?")
    314             || !strcmp(argv[i], "-help")
    315             || !strcmp(argv[i], "--help"))
    316         {
    317             showHelp();
    318             return 0;
     306    /* Failed result initially: */
     307    int iResultCode = 1;
     308
     309    /* Simulate try-catch block: */
     310    do
     311    {
     312#ifdef RT_OS_DARWIN
     313        ShutUpAppKit();
     314#endif /* RT_OS_DARWIN */
     315
     316        /* Console help preprocessing: */
     317        bool fHelpShown = false;
     318        for (int i = 0; i < argc; ++i)
     319        {
     320            if (   !strcmp(argv[i], "-h")
     321                || !strcmp(argv[i], "-?")
     322                || !strcmp(argv[i], "-help")
     323                || !strcmp(argv[i], "--help"))
     324            {
     325                showHelp();
     326                fHelpShown = true;
     327                break;
     328            }
     329        }
     330        if (fHelpShown)
     331        {
     332            iResultCode = 0;
     333            break;
    319334        }
    320335
    321336#if defined(DEBUG) && defined(Q_WS_X11) && defined(RT_OS_LINUX)
    322     /* Install our signal handler to backtrace the call stack: */
    323     struct sigaction sa;
    324     sa.sa_sigaction = bt_sighandler;
    325     sigemptyset(&sa.sa_mask);
    326     sa.sa_flags = SA_RESTART | SA_SIGINFO;
    327     sigaction(SIGSEGV, &sa, NULL);
    328     sigaction(SIGBUS, &sa, NULL);
    329     sigaction(SIGUSR1, &sa, NULL);
     337        /* Install our signal handler to backtrace the call stack: */
     338        struct sigaction sa;
     339        sa.sa_sigaction = bt_sighandler;
     340        sigemptyset(&sa.sa_mask);
     341        sa.sa_flags = SA_RESTART | SA_SIGINFO;
     342        sigaction(SIGSEGV, &sa, NULL);
     343        sigaction(SIGBUS, &sa, NULL);
     344        sigaction(SIGUSR1, &sa, NULL);
    330345#endif
    331346
    332347#ifdef QT_MAC_USE_COCOA
    333     /* Instantiate our NSApplication derivative before QApplication
    334      * forces NSApplication to be instantiated. */
    335     UICocoaApplication::instance();
     348        /* Instantiate our NSApplication derivative before QApplication
     349         * forces NSApplication to be instantiated. */
     350        UICocoaApplication::instance();
    336351#endif /* QT_MAC_USE_COCOA */
    337352
    338     qInstallMsgHandler(QtMessageOutput);
    339 
    340     int rc = 1; /* failure */
    341 
    342     /* Scope the QApplication variable: */
    343     {
     353        /* Install Qt console message handler: */
     354        qInstallMsgHandler(QtMessageOutput);
     355
    344356#ifdef Q_WS_X11
    345357        /* Qt has a complex algorithm for selecting the right visual which
     
    371383                                : "Failed to open the X11 display!\n",
    372384                     pszDisplay);
    373             return 0;
     385            break;
    374386        }
    375387        Visual *pVisual =   useDefaultVisual
     
    450462                break;
    451463
    452             /* Exit if VBoxGlobal unable to process arguments: */
     464            /* Exit if VBoxGlobal was able to pre-process arguments: */
    453465            if (vboxGlobal().processArgs())
    454                 return 0;
     466                break;
    455467
    456468#ifdef RT_OS_LINUX
     
    470482
    471483                /* Start application: */
    472                 rc = a.exec();
     484                iResultCode = a.exec();
    473485            }
     486            /* VM selector process: */
    474487            else
    475488            {
     
    501514
    502515                /* Start application: */
    503                 rc = a.exec();
     516                iResultCode = a.exec();
    504517            }
    505518        }
    506519        while (0);
    507520
    508         /* Create modal-window manager: */
     521        /* Destroy modal-window manager: */
    509522        UIModalWindowManager::destroy();
    510523    }
     524    while (0);
    511525
    512526    /* Finish logging: */
    513     LogFlowFunc(("rc=%d\n", rc));
     527    LogFlowFunc(("rc=%d\n", iResultCode));
    514528    LogFlowFuncLeave();
    515529
    516530    /* Return result: */
    517     return rc;
     531    return iResultCode;
    518532}
    519533
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