VirtualBox

Changeset 63044 in vbox for trunk/src


Ignore:
Timestamp:
Aug 5, 2016 1:27:06 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8422: Desktop-widget watchdog rework (part 11): Converting to singleton; using everywhere, not just under X11.

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

Legend:

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

    r63041 r63044  
    107107*********************************************************************************************************************************/
    108108
    109 UIDesktopWidgetWatchdog::UIDesktopWidgetWatchdog(QObject *pParent)
    110     : QObject(pParent)
    111 {
    112     /* Prepare: */
    113     prepare();
     109/* static */
     110UIDesktopWidgetWatchdog *UIDesktopWidgetWatchdog::m_spInstance = 0;
     111
     112/* static */
     113void UIDesktopWidgetWatchdog::create()
     114{
     115    /* Make sure instance isn't created: */
     116    AssertReturnVoid(!m_spInstance);
     117
     118    /* Create/prepare instance: */
     119    new UIDesktopWidgetWatchdog;
     120    AssertReturnVoid(m_spInstance);
     121    m_spInstance->prepare();
     122}
     123
     124/* static */
     125void UIDesktopWidgetWatchdog::destroy()
     126{
     127    /* Make sure instance is created: */
     128    AssertReturnVoid(m_spInstance);
     129
     130    /* Cleanup/destroy instance: */
     131    m_spInstance->cleanup();
     132    delete m_spInstance;
     133    AssertReturnVoid(!m_spInstance);
     134}
     135
     136UIDesktopWidgetWatchdog::UIDesktopWidgetWatchdog()
     137{
     138    /* Initialize instance: */
     139    m_spInstance = this;
    114140}
    115141
    116142UIDesktopWidgetWatchdog::~UIDesktopWidgetWatchdog()
    117143{
    118     /* Cleanup: */
    119     cleanup();
     144    /* Deinitialize instance: */
     145    m_spInstance = 0;
    120146}
    121147
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.h

    r63041 r63044  
    3131#endif /* QT_VERSION >= 0x050000 */
    3232
    33 /** QObject extension used as
     33/** Singleton QObject extension used as
    3434  * a desktop-widget watchdog aware
    3535  * of the host-screen geometry changes. */
     
    3737{
    3838    Q_OBJECT;
     39
     40    /** Constructs desktop-widget watchdog. */
     41    UIDesktopWidgetWatchdog();
     42    /** Destructs desktop-widget watchdog. */
     43    ~UIDesktopWidgetWatchdog();
    3944
    4045signals:
     
    5156public:
    5257
    53     /** Constructs watchdog for the @a pParent being passed into the base-class. */
    54     UIDesktopWidgetWatchdog(QObject *pParent);
    55     /** Destructs watchdog. */
    56     ~UIDesktopWidgetWatchdog();
     58    /** Returns the static instance of the desktop-widget watchdog. */
     59    static UIDesktopWidgetWatchdog *instance() { return m_spInstance; }
     60
     61    /** Creates the static instance of the desktop-widget watchdog. */
     62    static void create();
     63    /** Destroys the static instance of the desktop-widget watchdog. */
     64    static void destroy();
    5765
    5866    /** Returns the number of host-screens currently available on the system. */
     
    112120    void cleanup();
    113121
     122    /** Holds the static instance of the desktop-widget watchdog. */
     123    static UIDesktopWidgetWatchdog *m_spInstance;
     124
    114125#ifdef VBOX_WS_X11
    115126    /** Updates host-screen configuration according to new @a cHostScreenCount.
     
    130141};
    131142
     143/** 'Official' name for the desktop-widget watchdog singleton. */
     144#define gpDesktop UIDesktopWidgetWatchdog::instance()
     145
    132146#endif /* !___UIDesktopWidgetWatchdog_h___ */
    133147
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r62917 r63044  
    7777# include "UIIconPool.h"
    7878# include "UIVirtualBoxEventHandler.h"
     79# include "UIDesktopWidgetWatchdog.h"
    7980# ifdef VBOX_WS_X11
    8081#  include "UIHostComboEditor.h"
    81 #  include "UIDesktopWidgetWatchdog.h"
    8282#  ifndef VBOX_OSE
    8383#   include "VBoxLicenseViewer.h"
     
    237237    , m_fCompositingManagerRunning(false)
    238238    , m_enmWindowManagerType(X11WMType_Unknown)
    239     , m_pDesktopWidgetWatchdog(0)
    240239#endif /* VBOX_WS_X11 */
    241240#if defined(DEBUG_bird)
     
    362361#ifdef VBOX_WS_X11
    363362    /* Make sure desktop-widget watchdog already created: */
    364     AssertPtrReturn(m_pDesktopWidgetWatchdog, QApplication::desktop()->screenGeometry(iHostScreenIndex));
     363    AssertPtrReturn(gpDesktop, QApplication::desktop()->screenGeometry(iHostScreenIndex));
    365364    /* Redirect call to UIDesktopWidgetWatchdog: */
    366     return m_pDesktopWidgetWatchdog->screenGeometry(iHostScreenIndex);
     365    return gpDesktop->screenGeometry(iHostScreenIndex);
    367366#endif /* VBOX_WS_X11 */
    368367
     
    375374#ifdef VBOX_WS_X11
    376375    /* Make sure desktop-widget watchdog already created: */
    377     AssertPtrReturn(m_pDesktopWidgetWatchdog, QApplication::desktop()->availableGeometry(iHostScreenIndex));
     376    AssertPtrReturn(gpDesktop, QApplication::desktop()->availableGeometry(iHostScreenIndex));
    378377    /* Redirect call to UIDesktopWidgetWatchdog: */
    379     return m_pDesktopWidgetWatchdog->availableGeometry(iHostScreenIndex);
     378    return gpDesktop->availableGeometry(iHostScreenIndex);
    380379#endif /* VBOX_WS_X11 */
    381380
     
    39893988#endif /* VBOX_WS_MAC */
    39903989
    3991 #ifdef VBOX_WS_X11
    3992     /* Create desktop-widget watchdog instance: */
    3993     m_pDesktopWidgetWatchdog = new UIDesktopWidgetWatchdog(this);
    3994 #endif /* VBOX_WS_X11 */
     3990    /* Create desktop-widget watchdog: */
     3991    UIDesktopWidgetWatchdog::create();
    39953992
    39963993    /* Create message-center: */
     
    44914488    UIMessageCenter::destroy();
    44924489
     4490    /* Destroy desktop-widget watchdog: */
     4491    UIDesktopWidgetWatchdog::destroy();
     4492
    44934493    mValid = false;
    44944494}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r62917 r63044  
    6666class UIIconPoolGeneral;
    6767class UIThreadPool;
    68 #ifdef VBOX_WS_X11
    69 class UIDesktopWidgetWatchdog;
    70 #endif /* VBOX_WS_X11 */
    7168
    7269// VBoxGlobal class
     
    578575    /** X11: Holds the type of the Window Manager we are running under. */
    579576    X11WMType m_enmWindowManagerType;
    580 
    581     /** @name Host-screen geometry stuff
    582       * @{ */
    583         /** X11: Holds the desktop-widget watchdog instance aware of host-screen geometry changes. */
    584         UIDesktopWidgetWatchdog *m_pDesktopWidgetWatchdog;
    585     /** @} */
    586577#endif /* VBOX_WS_X11 */
    587578
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