VirtualBox

Changeset 84423 in vbox


Ignore:
Timestamp:
May 20, 2020 5:03:09 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138122
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Light cleanup in machine group settings saving functionality.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r84420 r84423  
    194194
    195195    /* Make sure all saving steps complete: */
    196     makeSureGroupDefinitionsSaveIsFinished();
     196    makeSureGroupSettingsSaveIsFinished();
    197197    makeSureGroupOrdersSaveIsFinished();
    198198
     
    306306bool UIChooserAbstractModel::isGroupSavingInProgress() const
    307307{
    308     return    UIThreadGroupDefinitionSave::instance()
     308    return    UIThreadGroupSettingsSave::instance()
    309309           || UIThreadGroupOrderSave::instance();
    310310}
     
    469469void UIChooserAbstractModel::sltStartGroupSaving()
    470470{
    471     saveGroupDefinitions();
     471    saveGroupSettings();
    472472    saveGroupOrders();
    473473}
     
    526526}
    527527
    528 void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete()
    529 {
    530     makeSureGroupDefinitionsSaveIsFinished();
     528void UIChooserAbstractModel::sltGroupSettingsSaveComplete()
     529{
     530    makeSureGroupSettingsSaveIsFinished();
    531531    emit sigGroupSavingStateChanged();
    532532}
     
    613613            createLocalMachineNode(getLocalGroupNode(strGroup, invisibleRoot(), fMakeItVisible), comMachine);
    614614        }
    615         /* Update group definitions: */
     615        /* Update group settings: */
    616616        m_groups[toOldStyleUuid(uId)] = groupList;
    617617    }
     
    648648    /* Create machine-item with found group-item as parent: */
    649649    createCloudMachineNode(getCloudGroupNode(strGroup, invisibleRoot(), fMakeItVisible), comMachine);
    650     /* Update group definitions: */
     650    /* Update group settings: */
    651651    const QStringList groupList(strGroup);
    652652    m_groups[toOldStyleUuid(uId)] = groupList;
     
    992992}
    993993
    994 void UIChooserAbstractModel::saveGroupDefinitions()
    995 {
    996     /* Make sure there is no group save activity: */
    997     if (UIThreadGroupDefinitionSave::instance())
     994void UIChooserAbstractModel::saveGroupSettings()
     995{
     996    /* Make sure there is no group settings saving activity: */
     997    if (UIThreadGroupSettingsSave::instance())
    998998        return;
    999999
    10001000    /* Prepare full group map: */
    10011001    QMap<QString, QStringList> groups;
    1002     gatherGroupDefinitions(groups, invisibleRoot());
     1002    gatherGroupSettings(groups, invisibleRoot());
    10031003
    10041004    /* Save information in other thread: */
    1005     UIThreadGroupDefinitionSave::prepare();
     1005    UIThreadGroupSettingsSave::prepare();
    10061006    emit sigGroupSavingStateChanged();
    1007     connect(UIThreadGroupDefinitionSave::instance(), &UIThreadGroupDefinitionSave::sigReload,
     1007    connect(UIThreadGroupSettingsSave::instance(), &UIThreadGroupSettingsSave::sigReload,
    10081008            this, &UIChooserAbstractModel::sltReloadMachine);
    1009     UIThreadGroupDefinitionSave::instance()->configure(this, m_groups, groups);
    1010     UIThreadGroupDefinitionSave::instance()->start();
     1009    UIThreadGroupSettingsSave::instance()->configure(this, m_groups, groups);
     1010    UIThreadGroupSettingsSave::instance()->start();
    10111011    m_groups = groups;
    10121012}
     
    10291029}
    10301030
    1031 void UIChooserAbstractModel::gatherGroupDefinitions(QMap<QString, QStringList> &definitions,
    1032                                                     UIChooserNode *pParentGroup)
     1031void UIChooserAbstractModel::gatherGroupSettings(QMap<QString, QStringList> &settings,
     1032                                                 UIChooserNode *pParentGroup)
    10331033{
    10341034    /* Iterate over all the machine-nodes: */
     
    10421042        if (   pMachineNode->cacheType() == UIVirtualMachineItemType_Local
    10431043            && pMachineNode->accessible())
    1044             definitions[toOldStyleUuid(pMachineNode->id())] << pParentGroup->fullName();
     1044            settings[toOldStyleUuid(pMachineNode->id())] << pParentGroup->fullName();
    10451045    }
    10461046    /* Iterate over all the group-nodes: */
    10471047    foreach (UIChooserNode *pNode, pParentGroup->nodes(UIChooserNodeType_Group))
    1048         gatherGroupDefinitions(definitions, pNode);
     1048        gatherGroupSettings(settings, pNode);
    10491049}
    10501050
     
    10841084}
    10851085
    1086 void UIChooserAbstractModel::makeSureGroupDefinitionsSaveIsFinished()
     1086void UIChooserAbstractModel::makeSureGroupSettingsSaveIsFinished()
    10871087{
    10881088    /* Cleanup if necessary: */
    1089     if (UIThreadGroupDefinitionSave::instance())
    1090         UIThreadGroupDefinitionSave::cleanup();
     1089    if (UIThreadGroupSettingsSave::instance())
     1090        UIThreadGroupSettingsSave::cleanup();
    10911091}
    10921092
     
    11001100
    11011101/*********************************************************************************************************************************
    1102 *   Class UIThreadGroupDefinitionSave implementation.                                                                            *
     1102*   Class UIThreadGroupSettingsSave implementation.                                                                              *
    11031103*********************************************************************************************************************************/
    11041104
    11051105/* static */
    1106 UIThreadGroupDefinitionSave *UIThreadGroupDefinitionSave::s_pInstance = 0;
     1106UIThreadGroupSettingsSave *UIThreadGroupSettingsSave::s_pInstance = 0;
    11071107
    11081108/* static */
    1109 UIThreadGroupDefinitionSave *UIThreadGroupDefinitionSave::instance()
     1109UIThreadGroupSettingsSave *UIThreadGroupSettingsSave::instance()
    11101110{
    11111111    return s_pInstance;
     
    11131113
    11141114/* static */
    1115 void UIThreadGroupDefinitionSave::prepare()
    1116 {
    1117     /* Make sure instance not prepared: */
     1115void UIThreadGroupSettingsSave::prepare()
     1116{
     1117    /* Make sure instance is not prepared: */
    11181118    if (s_pInstance)
    11191119        return;
    11201120
    11211121    /* Crate instance: */
    1122     new UIThreadGroupDefinitionSave;
     1122    new UIThreadGroupSettingsSave;
    11231123}
    11241124
    11251125/* static */
    1126 void UIThreadGroupDefinitionSave::cleanup()
    1127 {
    1128     /* Make sure instance prepared: */
     1126void UIThreadGroupSettingsSave::cleanup()
     1127{
     1128    /* Make sure instance is prepared: */
    11291129    if (!s_pInstance)
    11301130        return;
    11311131
    1132     /* Crate instance: */
     1132    /* Delete instance: */
    11331133    delete s_pInstance;
    11341134}
    11351135
    1136 void UIThreadGroupDefinitionSave::configure(QObject *pParent,
    1137                                             const QMap<QString, QStringList> &oldLists,
    1138                                             const QMap<QString, QStringList> &newLists)
     1136void UIThreadGroupSettingsSave::configure(QObject *pParent,
     1137                                          const QMap<QString, QStringList> &oldLists,
     1138                                          const QMap<QString, QStringList> &newLists)
    11391139{
    11401140    m_oldLists = oldLists;
     
    11431143    AssertPtrReturnVoid(pChooserAbstractModel);
    11441144    {
    1145         connect(this, &UIThreadGroupDefinitionSave::sigComplete,
    1146                 pChooserAbstractModel, &UIChooserAbstractModel::sltGroupDefinitionsSaveComplete);
    1147     }
    1148 }
    1149 
    1150 UIThreadGroupDefinitionSave::UIThreadGroupDefinitionSave()
     1145        connect(this, &UIThreadGroupSettingsSave::sigComplete,
     1146                pChooserAbstractModel, &UIChooserAbstractModel::sltGroupSettingsSaveComplete);
     1147    }
     1148}
     1149
     1150UIThreadGroupSettingsSave::UIThreadGroupSettingsSave()
    11511151{
    11521152    /* Assign instance: */
     
    11541154}
    11551155
    1156 UIThreadGroupDefinitionSave::~UIThreadGroupDefinitionSave()
    1157 {
    1158     /* Wait: */
     1156UIThreadGroupSettingsSave::~UIThreadGroupSettingsSave()
     1157{
     1158    /* Make sure thread work is complete: */
    11591159    wait();
    11601160
     
    11631163}
    11641164
    1165 void UIThreadGroupDefinitionSave::run()
     1165void UIThreadGroupSettingsSave::run()
    11661166{
    11671167    /* COM prepare: */
     
    11851185         * with common cleanup in case of failure.
    11861186         * We have to simulate a try-catch block. */
    1187         CSession session;
    1188         CMachine machine;
     1187        CSession comSession;
     1188        CMachine comMachine;
    11891189        do
    11901190        {
    11911191            /* 1. Open session: */
    1192             session = uiCommon().openSession(QUuid(strId));
    1193             if (session.isNull())
     1192            comSession = uiCommon().openSession(QUuid(strId));
     1193            if (comSession.isNull())
    11941194                break;
    11951195
    11961196            /* 2. Get session machine: */
    1197             machine = session.GetMachine();
    1198             if (machine.isNull())
     1197            comMachine = comSession.GetMachine();
     1198            if (comMachine.isNull())
    11991199                break;
    12001200
    12011201            /* 3. Set new groups: */
    1202             machine.SetGroups(newGroupList.toVector());
    1203             if (!machine.isOk())
     1202            comMachine.SetGroups(newGroupList.toVector());
     1203            if (!comMachine.isOk())
    12041204            {
    1205                 msgCenter().cannotSetGroups(machine);
     1205                msgCenter().cannotSetGroups(comMachine);
    12061206                break;
    12071207            }
    12081208
    12091209            /* 4. Save settings: */
    1210             machine.SaveSettings();
    1211             if (!machine.isOk())
     1210            comMachine.SaveSettings();
     1211            if (!comMachine.isOk())
    12121212            {
    1213                 msgCenter().cannotSaveMachineSettings(machine);
     1213                msgCenter().cannotSaveMachineSettings(comMachine);
    12141214                break;
    12151215            }
     
    12171217
    12181218        /* Cleanup if necessary: */
    1219         if (machine.isNull() || !machine.isOk())
     1219        if (comMachine.isNull() || !comMachine.isOk())
    12201220            emit sigReload(QUuid(strId));
    1221         if (!session.isNull())
    1222             session.UnlockMachine();
     1221        if (!comSession.isNull())
     1222            comSession.UnlockMachine();
    12231223    }
    12241224
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r84420 r84423  
    128128    /** @name Group saving stuff.
    129129      * @{ */
    130         /** Handles group definition saving complete. */
    131         void sltGroupDefinitionsSaveComplete();
     130        /** Handles group settings saving complete. */
     131        void sltGroupSettingsSaveComplete();
    132132        /** Handles group order saving complete. */
    133133        void sltGroupOrdersSaveComplete();
     
    225225    /** @name Group saving stuff.
    226226      * @{ */
    227         /** Saves group definitions. */
    228         void saveGroupDefinitions();
     227        /** Saves group settings. */
     228        void saveGroupSettings();
    229229        /** Saves group orders. */
    230230        void saveGroupOrders();
    231231
    232         /** Gathers group @a definitions of @a pParentGroup. */
    233         void gatherGroupDefinitions(QMap<QString, QStringList> &definitions, UIChooserNode *pParentGroup);
     232        /** Gathers group @a settings of @a pParentGroup. */
     233        void gatherGroupSettings(QMap<QString, QStringList> &settings, UIChooserNode *pParentGroup);
    234234        /** Gathers group @a orders of @a pParentGroup. */
    235235        void gatherGroupOrders(QMap<QString, QStringList> &orders, UIChooserNode *pParentGroup);
    236236
    237         /** Makes sure group definitions saving is finished. */
    238         void makeSureGroupDefinitionsSaveIsFinished();
     237        /** Makes sure group settings saving is finished. */
     238        void makeSureGroupSettingsSaveIsFinished();
    239239        /** Makes sure group orders saving is finished. */
    240240        void makeSureGroupOrdersSaveIsFinished();
     
    261261    /** @name Group saving stuff.
    262262      * @{ */
    263         /** Holds the consolidated map of group definitions/orders. */
     263        /** Holds the consolidated map of group settings/orders. */
    264264        QMap<QString, QStringList>  m_groups;
    265265    /** @} */
     
    267267
    268268
    269 /** QThread subclass allowing to save group definitions asynchronously. */
    270 class UIThreadGroupDefinitionSave : public QThread
     269/** QThread subclass allowing to save group settings asynchronously. */
     270class UIThreadGroupSettingsSave : public QThread
    271271{
    272272    Q_OBJECT;
     
    282282public:
    283283
    284     /** Returns group saving thread instance. */
    285     static UIThreadGroupDefinitionSave* instance();
    286     /** Prepares group saving thread instance. */
     284    /** Returns group settings saving thread instance. */
     285    static UIThreadGroupSettingsSave *instance();
     286    /** Prepares group settings saving thread instance. */
    287287    static void prepare();
    288     /** Cleanups group saving thread instance. */
     288    /** Cleanups group settings saving thread instance. */
    289289    static void cleanup();
    290290
    291     /** Configures @a groups saving thread with corresponding @a pListener.
    292       * @param  oldLists  Brings the old definition list to be compared.
    293       * @param  newLists  Brings the new definition list to be saved. */
     291    /** Configures @a group settings saving thread with corresponding @a pListener.
     292      * @param  oldLists  Brings the old settings list to be compared.
     293      * @param  newLists  Brings the new settings list to be saved. */
    294294    void configure(QObject *pParent,
    295295                   const QMap<QString, QStringList> &oldLists,
     
    298298protected:
    299299
    300     /** Constructs group saving thread. */
    301     UIThreadGroupDefinitionSave();
    302     /** Destructs group saving thread. */
    303     virtual ~UIThreadGroupDefinitionSave() /* override */;
     300    /** Constructs group settings saving thread. */
     301    UIThreadGroupSettingsSave();
     302    /** Destructs group settings saving thread. */
     303    virtual ~UIThreadGroupSettingsSave() /* override */;
    304304
    305305    /** Contains a thread task to be executed. */
     
    307307
    308308    /** Holds the singleton instance. */
    309     static UIThreadGroupDefinitionSave *s_pInstance;
    310 
    311     /** Holds the map of group definitions to be compared. */
     309    static UIThreadGroupSettingsSave *s_pInstance;
     310
     311    /** Holds the map of group settings to be compared. */
    312312    QMap<QString, QStringList> m_oldLists;
    313     /** Holds the map of group definitions to be saved. */
     313    /** Holds the map of group settings to be saved. */
    314314    QMap<QString, QStringList> m_newLists;
    315315};
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