VirtualBox

Changeset 90560 in vbox for trunk/src


Ignore:
Timestamp:
Aug 7, 2021 7:36:02 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Moving singleton functionality from UIDownloaderExtensionPack to UINotificationDownloaderExtensionPack.

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

Legend:

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

    r90541 r90560  
    3434
    3535
    36 /* static */
    37 UIDownloaderExtensionPack *UIDownloaderExtensionPack::s_pInstance = 0;
    38 
    39 /* static */
    40 UIDownloaderExtensionPack *UIDownloaderExtensionPack::create()
    41 {
    42     if (!s_pInstance)
    43         s_pInstance = new UIDownloaderExtensionPack;
    44     return s_pInstance;
    45 }
    46 
    4736UIDownloaderExtensionPack::UIDownloaderExtensionPack()
    4837{
    49     /* Prepare instance: */
    50     if (!s_pInstance)
    51         s_pInstance = this;
    52 
    5338    /* Get version number and adjust it for test and trunk builds. The server only has official releases. */
    5439    const QString strVersion = UIVersion(uiCommon().vboxVersionStringNormalized()).effectiveReleasedVersion().toString();
     
    6651    setTarget(strTarget);
    6752    setPathSHA256SumsFile(strPathSHA256SumsFile);
    68 }
    69 
    70 UIDownloaderExtensionPack::~UIDownloaderExtensionPack()
    71 {
    72     /* Cleanup instance: */
    73     if (s_pInstance == this)
    74         s_pInstance = 0;
    7553}
    7654
     
    187165    }
    188166}
    189 
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UIDownloaderExtensionPack.h

    r90541 r90560  
    4343public:
    4444
    45     /** Creates downloader instance. */
    46     static UIDownloaderExtensionPack *create();
    47     /** Returns current downloader instance. */
    48     static UIDownloaderExtensionPack *current() { return s_pInstance; }
     45    /** Constructs downloader. */
     46    UIDownloaderExtensionPack();
    4947
    5048private:
    51 
    52     /** Constructs downloader. */
    53     UIDownloaderExtensionPack();
    54     /** Destructs downloader. */
    55     ~UIDownloaderExtensionPack();
    5649
    5750    /** Returns description of the current network operation. */
     
    6558    virtual void handleVerifiedObject(UINetworkReply *pReply) /* override */;
    6659
    67     /** Holds the static singleton instance. */
    68     static UIDownloaderExtensionPack *s_pInstance;
    69 
    7060    /** Holds the cached received data awaiting for verification. */
    7161    QByteArray m_receivedData;
     
    7363
    7464#endif /* !FEQT_INCLUDED_SRC_networking_UIDownloaderExtensionPack_h */
    75 
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.cpp

    r90559 r90560  
    2727#include "UICommon.h"
    2828#include "VBoxUtils.h"
    29 #include "UIDownloaderExtensionPack.h"
    3029#include "UIExtraDataManager.h"
    3130#include "UIMessageCenter.h"
     
    420419
    421420    /* Return if already downloading: */
    422     if (UIDownloaderExtensionPack::current())
     421    if (UINotificationDownloaderExtensionPack::exists())
    423422    {
    424423        emit sigStepComplete();
     
    491490
    492491    /* Download extension pack: */
    493     UINotificationDownloaderExtensionPack *pNotification = new UINotificationDownloaderExtensionPack(GUI_ExtPackName);
     492    UINotificationDownloaderExtensionPack *pNotification = UINotificationDownloaderExtensionPack::instance(GUI_ExtPackName);
    494493    /* After downloading finished => propose to install the Extension Pack: */
    495494    connect(pNotification, &UINotificationDownloaderExtensionPack::sigExtensionPackDownloaded,
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90559 r90560  
    14921492*********************************************************************************************************************************/
    14931493
     1494/* static */
     1495UINotificationDownloaderExtensionPack *UINotificationDownloaderExtensionPack::s_pInstance = 0;
     1496
     1497/* static */
     1498UINotificationDownloaderExtensionPack *UINotificationDownloaderExtensionPack::instance(const QString &strPackName)
     1499{
     1500    if (!s_pInstance)
     1501        new UINotificationDownloaderExtensionPack(strPackName);
     1502    return s_pInstance;
     1503}
     1504
     1505/* static */
     1506bool UINotificationDownloaderExtensionPack::exists()
     1507{
     1508    return !!s_pInstance;
     1509}
     1510
    14941511UINotificationDownloaderExtensionPack::UINotificationDownloaderExtensionPack(const QString &strPackName)
    14951512    : m_strPackName(strPackName)
    14961513{
     1514    s_pInstance = this;
     1515}
     1516
     1517UINotificationDownloaderExtensionPack::~UINotificationDownloaderExtensionPack()
     1518{
     1519    s_pInstance = 0;
    14971520}
    14981521
     
    15101533{
    15111534    /* Create and configure the Extension Pack downloader: */
    1512     UIDownloaderExtensionPack *pDownloader = UIDownloaderExtensionPack::create();
     1535    UIDownloaderExtensionPack *pDownloader = new UIDownloaderExtensionPack;
    15131536    if (pDownloader)
    15141537    {
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90559 r90560  
    11181118};
    11191119
    1120 /** UINotificationDownloader extension for Extension Pack downloading functionality. */
     1120/** UINotificationDownloader extension for extension pack downloading functionality. */
    11211121class SHARED_LIBRARY_STUFF UINotificationDownloaderExtensionPack : public UINotificationDownloader
    11221122{
     
    11351135public:
    11361136
    1137     /** Constructs host-only network interface remove notification-progress. */
     1137    /** Returns singleton instance, creates if necessary.
     1138      * @param  strPackName  Brings the package name. */
     1139    static UINotificationDownloaderExtensionPack *instance(const QString &strPackName);
     1140    /** Returns whether singleton instance already created. */
     1141    static bool exists();
     1142
     1143    /** Destructs extension pack downloading notification-progress.
     1144      * @note  Notification-center can destroy us at any time. */
     1145    virtual ~UINotificationDownloaderExtensionPack() /* override final */;
     1146
     1147protected:
     1148
     1149    /** Constructs extension pack downloading notification-progress.
     1150      * @param  strPackName  Brings the package name. */
    11381151    UINotificationDownloaderExtensionPack(const QString &strPackName);
    11391152
    1140 protected:
    1141 
    11421153    /** Returns object name. */
    11431154    virtual QString name() const /* override final */;
     
    11491160private:
    11501161
    1151     /** Holds the pack being dowloaded. */
     1162    /** Holds the singleton instance. */
     1163    static UINotificationDownloaderExtensionPack *s_pInstance;
     1164
     1165    /** Holds the name of pack being dowloaded. */
    11521166    QString  m_strPackName;
    11531167};
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