VirtualBox

Ignore:
Timestamp:
Mar 9, 2023 12:01:30 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Simplify UIStarter code.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

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

    r98859 r98890  
    4242
    4343
    44 /* static */
    45 UIStarter *UIStarter::s_pInstance = 0;
    46 
    47 /* static */
    48 void UIStarter::create()
    49 {
    50     /* Pretect versus double 'new': */
    51     if (s_pInstance)
    52         return;
    53 
    54     /* Create instance: */
    55     new UIStarter;
    56 }
    57 
    58 /* static */
    59 void UIStarter::destroy()
    60 {
    61     /* Pretect versus double 'delete': */
    62     if (!s_pInstance)
    63         return;
    64 
    65     /* Destroy instance: */
    66     delete s_pInstance;
    67 }
    68 
    6944UIStarter::UIStarter()
    70 {
    71     /* Assign instance: */
    72     s_pInstance = this;
    73 }
    74 
    75 UIStarter::~UIStarter()
    76 {
    77     /* Unassign instance: */
    78     s_pInstance = 0;
    79 }
    80 
    81 void UIStarter::init()
    8245{
    8346    /* Listen for UICommon signals: */
     
    8851}
    8952
    90 void UIStarter::deinit()
     53UIStarter::~UIStarter()
    9154{
    9255    /* Listen for UICommon signals no more: */
     
    10568#ifndef VBOX_RUNTIME_UI
    10669
    107     /* Make sure Selector UI is permitted, quit if not: */
     70    /* Make sure Manager UI is permitted, quit if not: */
    10871    if (gEDataManager->guiFeatureEnabled(GUIFeatureType_NoSelector))
    10972    {
     
    13093#else /* VBOX_RUNTIME_UI */
    13194
    132     /* Make sure Runtime UI is even possible, quit if not: */
     95    /* Make sure Runtime UI is possible at all, quit if not: */
    13396    if (uiCommon().managedVMUuid().isNull())
    13497    {
     
    137100    }
    138101
    139     /* Make sure machine is started, quit if not: */
     102    /* Try to start virtual machine, quit if failed: */
    140103    if (!UIMachine::startMachine(uiCommon().managedVMUuid()))
    141104        return QApplication::quit();
     
    157120#ifndef VBOX_RUNTIME_UI
    158121    /* Destroy Manager UI: */
    159     if (gpManager)
    160         UIVirtualBoxManager::destroy();
     122    UIVirtualBoxManager::destroy();
    161123#else
    162124    /* Destroy Runtime UI: */
    163     if (gpMachine)
    164         UIMachine::destroy();
     125    UIMachine::destroy();
    165126#endif
    166127}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIStarter.h

    r98103 r98890  
    3535#include <QObject>
    3636
    37 /** QObject subclass allowing to control GUI part
     37/** QObject subclass allowing to start/close GUI parts
    3838  * of VirtualBox application in sync/async modes. */
    3939class UIStarter : public QObject
     
    4141    Q_OBJECT;
    4242
     43public:
     44
    4345    /** Constructs UI starter. */
    4446    UIStarter();
    4547    /** Destructs UI starter. */
    4648    virtual ~UIStarter();
    47 
    48 public:
    49 
    50     /** Returns the singleton UI starter instance. */
    51     static UIStarter *instance() { return s_pInstance; }
    52 
    53     /** Create the singleton UI starter instance. */
    54     static void create();
    55     /** Create the singleton UI starter instance. */
    56     static void destroy();
    57 
    58     /** Init UICommon connections. */
    59     void init();
    60     /** Deinit UICommon connections. */
    61     void deinit();
    6249
    6350private slots:
     
    6956    /** Closes corresponding part of the UI. */
    7057    void sltCloseUI();
    71 
    72 private:
    73 
    74     /** Holds the singleton UI starter instance. */
    75     static UIStarter *s_pInstance;
    7658};
    7759
    78 /** Singleton UI starter 'official' name. */
    79 #define gStarter UIStarter::instance()
    80 
    8160#endif /* !FEQT_INCLUDED_SRC_globals_UIStarter_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r98885 r98890  
    521521        UIModalWindowManager::create();
    522522
    523         /* Create UI starter: */
    524         UIStarter::create();
    525523#ifndef VBOX_RUNTIME_UI
    526524        /* Create global app instance for Selector UI: */
     
    540538            if (uiCommon().processArgs())
    541539                break;
    542 
    543             /* Init link between UI starter and global app instance: */
    544             gStarter->init();
    545540
    546541            // WORKAROUND:
     
    555550            a.setQuitOnLastWindowClosed(false);
    556551
     552            /* Create UI starter: */
     553            UIStarter uiStarter;
    557554            /* Request to Start UI _after_ QApplication executed: */
    558             QMetaObject::invokeMethod(gStarter, "sltStartUI", Qt::QueuedConnection);
     555            QMetaObject::invokeMethod(&uiStarter, "sltStartUI", Qt::QueuedConnection);
    559556
    560557            /* Start application: */
    561558            iResultCode = a.exec();
    562 
    563             /* Break link between UI starter and global app instance: */
    564             gStarter->deinit();
    565559        }
    566560        while (0);
     
    568562        /* Destroy global app instance: */
    569563        UICommon::destroy();
    570         /* Destroy UI starter: */
    571         UIStarter::destroy();
    572564
    573565        /* Destroy modal-window manager: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r98335 r98890  
    452452{
    453453    /* Make sure VirtualBox Manager is created: */
    454     AssertPtrReturnVoid(s_pInstance);
     454    if (!s_pInstance)
     455        return;
    455456
    456457    /* Unregister in the modal window manager: */
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