VirtualBox

Changeset 104967 in vbox


Ignore:
Timestamp:
Jun 19, 2024 6:43:01 PM (3 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: Reworking singleton stuff a bit for Extra-data Manager; It's necessary for more predictable place of extra-data manager init; Lazy-init is evil.

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

Legend:

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

    r104642 r104967  
    55
    66/*
    7  * Copyright (C) 2010-2023 Oracle and/or its affiliates.
     7 * Copyright (C) 2010-2024 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    5454/* GUI includes: */
    5555#include "UICommon.h"
    56 #include "UIActionPool.h"
    5756#include "UIConverter.h"
    5857#include "UIDesktopWidgetWatchdog.h"
     
    20182017
    20192018/* static */
    2020 UIExtraDataManager* UIExtraDataManager::instance()
    2021 {
    2022     /* Create/prepare instance if not yet exists: */
    2023     if (!s_pInstance)
    2024     {
    2025         new UIExtraDataManager;
    2026         s_pInstance->prepare();
    2027     }
    2028     /* Return instance: */
    2029     return s_pInstance;
     2019void UIExtraDataManager::create()
     2020{
     2021    AssertReturnVoid(!s_pInstance);
     2022    new UIExtraDataManager;
     2023    s_pInstance->prepare();
    20302024}
    20312025
     
    20332027void UIExtraDataManager::destroy()
    20342028{
    2035     /* Destroy/cleanup instance if still exists: */
    2036     if (s_pInstance)
    2037     {
    2038         s_pInstance->cleanup();
    2039         delete s_pInstance;
    2040     }
     2029    AssertPtrReturnVoid(s_pInstance);
     2030    s_pInstance->cleanup();
     2031    delete s_pInstance;
     2032}
     2033
     2034/* static */
     2035UIExtraDataManager *UIExtraDataManager::instance()
     2036{
     2037    /* This is the fallback behavior, we need the lazy-init here
     2038     * only to make sure gEDataManager is never NULL. */
     2039    AssertPtr(s_pInstance);
     2040    if (!s_pInstance)
     2041        create();
     2042    return s_pInstance;
    20412043}
    20422044
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r104642 r104967  
    55
    66/*
    7  * Copyright (C) 2010-2023 Oracle and/or its affiliates.
     7 * Copyright (C) 2010-2024 Oracle and/or its affiliates.
    88 *
    99 * This file is part of VirtualBox base platform packages, as
     
    6363    Q_OBJECT;
    6464
    65     /** Extra-data Manager constructor. */
     65    /** Constructs Extra-data Manager. */
    6666    UIExtraDataManager();
    67     /** Extra-data Manager destructor. */
    68     ~UIExtraDataManager();
     67    /** Destructs Extra-data Manager. */
     68    virtual ~UIExtraDataManager();
    6969
    7070signals:
     
    147147    static const QUuid GlobalID;
    148148
     149    /** Singleton object contructor. */
     150    static void create();
     151    /** Singleton object destructor. */
     152    static void destroy();
    149153    /** Static Extra-data Manager instance/constructor. */
    150154    static UIExtraDataManager* instance();
    151     /** Static Extra-data Manager destructor. */
    152     static void destroy();
    153155
    154156#ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r104904 r104967  
    251251    connect(gpGlobalSession, &UIGlobalSession::sigVBoxSVCAvailabilityChange,
    252252            this, &UICommon::sltHandleVBoxSVCAvailabilityChange);
     253
     254    /* Create extra-data manager right after COM init: */
     255    UIExtraDataManager::create();
    253256
    254257    /* Prepare thread-pool instances: */
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