Changeset 84423 in vbox
- Timestamp:
- May 20, 2020 5:03:09 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 138122
- 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 194 194 195 195 /* Make sure all saving steps complete: */ 196 makeSureGroup DefinitionsSaveIsFinished();196 makeSureGroupSettingsSaveIsFinished(); 197 197 makeSureGroupOrdersSaveIsFinished(); 198 198 … … 306 306 bool UIChooserAbstractModel::isGroupSavingInProgress() const 307 307 { 308 return UIThreadGroup DefinitionSave::instance()308 return UIThreadGroupSettingsSave::instance() 309 309 || UIThreadGroupOrderSave::instance(); 310 310 } … … 469 469 void UIChooserAbstractModel::sltStartGroupSaving() 470 470 { 471 saveGroup Definitions();471 saveGroupSettings(); 472 472 saveGroupOrders(); 473 473 } … … 526 526 } 527 527 528 void UIChooserAbstractModel::sltGroup DefinitionsSaveComplete()529 { 530 makeSureGroup DefinitionsSaveIsFinished();528 void UIChooserAbstractModel::sltGroupSettingsSaveComplete() 529 { 530 makeSureGroupSettingsSaveIsFinished(); 531 531 emit sigGroupSavingStateChanged(); 532 532 } … … 613 613 createLocalMachineNode(getLocalGroupNode(strGroup, invisibleRoot(), fMakeItVisible), comMachine); 614 614 } 615 /* Update group definitions: */615 /* Update group settings: */ 616 616 m_groups[toOldStyleUuid(uId)] = groupList; 617 617 } … … 648 648 /* Create machine-item with found group-item as parent: */ 649 649 createCloudMachineNode(getCloudGroupNode(strGroup, invisibleRoot(), fMakeItVisible), comMachine); 650 /* Update group definitions: */650 /* Update group settings: */ 651 651 const QStringList groupList(strGroup); 652 652 m_groups[toOldStyleUuid(uId)] = groupList; … … 992 992 } 993 993 994 void UIChooserAbstractModel::saveGroup Definitions()995 { 996 /* Make sure there is no group s aveactivity: */997 if (UIThreadGroup DefinitionSave::instance())994 void UIChooserAbstractModel::saveGroupSettings() 995 { 996 /* Make sure there is no group settings saving activity: */ 997 if (UIThreadGroupSettingsSave::instance()) 998 998 return; 999 999 1000 1000 /* Prepare full group map: */ 1001 1001 QMap<QString, QStringList> groups; 1002 gatherGroup Definitions(groups, invisibleRoot());1002 gatherGroupSettings(groups, invisibleRoot()); 1003 1003 1004 1004 /* Save information in other thread: */ 1005 UIThreadGroup DefinitionSave::prepare();1005 UIThreadGroupSettingsSave::prepare(); 1006 1006 emit sigGroupSavingStateChanged(); 1007 connect(UIThreadGroup DefinitionSave::instance(), &UIThreadGroupDefinitionSave::sigReload,1007 connect(UIThreadGroupSettingsSave::instance(), &UIThreadGroupSettingsSave::sigReload, 1008 1008 this, &UIChooserAbstractModel::sltReloadMachine); 1009 UIThreadGroup DefinitionSave::instance()->configure(this, m_groups, groups);1010 UIThreadGroup DefinitionSave::instance()->start();1009 UIThreadGroupSettingsSave::instance()->configure(this, m_groups, groups); 1010 UIThreadGroupSettingsSave::instance()->start(); 1011 1011 m_groups = groups; 1012 1012 } … … 1029 1029 } 1030 1030 1031 void UIChooserAbstractModel::gatherGroup Definitions(QMap<QString, QStringList> &definitions,1032 1031 void UIChooserAbstractModel::gatherGroupSettings(QMap<QString, QStringList> &settings, 1032 UIChooserNode *pParentGroup) 1033 1033 { 1034 1034 /* Iterate over all the machine-nodes: */ … … 1042 1042 if ( pMachineNode->cacheType() == UIVirtualMachineItemType_Local 1043 1043 && pMachineNode->accessible()) 1044 definitions[toOldStyleUuid(pMachineNode->id())] << pParentGroup->fullName();1044 settings[toOldStyleUuid(pMachineNode->id())] << pParentGroup->fullName(); 1045 1045 } 1046 1046 /* Iterate over all the group-nodes: */ 1047 1047 foreach (UIChooserNode *pNode, pParentGroup->nodes(UIChooserNodeType_Group)) 1048 gatherGroup Definitions(definitions, pNode);1048 gatherGroupSettings(settings, pNode); 1049 1049 } 1050 1050 … … 1084 1084 } 1085 1085 1086 void UIChooserAbstractModel::makeSureGroup DefinitionsSaveIsFinished()1086 void UIChooserAbstractModel::makeSureGroupSettingsSaveIsFinished() 1087 1087 { 1088 1088 /* Cleanup if necessary: */ 1089 if (UIThreadGroup DefinitionSave::instance())1090 UIThreadGroup DefinitionSave::cleanup();1089 if (UIThreadGroupSettingsSave::instance()) 1090 UIThreadGroupSettingsSave::cleanup(); 1091 1091 } 1092 1092 … … 1100 1100 1101 1101 /********************************************************************************************************************************* 1102 * Class UIThreadGroup DefinitionSave implementation.*1102 * Class UIThreadGroupSettingsSave implementation. * 1103 1103 *********************************************************************************************************************************/ 1104 1104 1105 1105 /* static */ 1106 UIThreadGroup DefinitionSave *UIThreadGroupDefinitionSave::s_pInstance = 0;1106 UIThreadGroupSettingsSave *UIThreadGroupSettingsSave::s_pInstance = 0; 1107 1107 1108 1108 /* static */ 1109 UIThreadGroup DefinitionSave *UIThreadGroupDefinitionSave::instance()1109 UIThreadGroupSettingsSave *UIThreadGroupSettingsSave::instance() 1110 1110 { 1111 1111 return s_pInstance; … … 1113 1113 1114 1114 /* static */ 1115 void UIThreadGroup DefinitionSave::prepare()1116 { 1117 /* Make sure instance not prepared: */1115 void UIThreadGroupSettingsSave::prepare() 1116 { 1117 /* Make sure instance is not prepared: */ 1118 1118 if (s_pInstance) 1119 1119 return; 1120 1120 1121 1121 /* Crate instance: */ 1122 new UIThreadGroup DefinitionSave;1122 new UIThreadGroupSettingsSave; 1123 1123 } 1124 1124 1125 1125 /* static */ 1126 void UIThreadGroup DefinitionSave::cleanup()1127 { 1128 /* Make sure instance prepared: */1126 void UIThreadGroupSettingsSave::cleanup() 1127 { 1128 /* Make sure instance is prepared: */ 1129 1129 if (!s_pInstance) 1130 1130 return; 1131 1131 1132 /* Crate instance: */1132 /* Delete instance: */ 1133 1133 delete s_pInstance; 1134 1134 } 1135 1135 1136 void UIThreadGroup DefinitionSave::configure(QObject *pParent,1137 1138 1136 void UIThreadGroupSettingsSave::configure(QObject *pParent, 1137 const QMap<QString, QStringList> &oldLists, 1138 const QMap<QString, QStringList> &newLists) 1139 1139 { 1140 1140 m_oldLists = oldLists; … … 1143 1143 AssertPtrReturnVoid(pChooserAbstractModel); 1144 1144 { 1145 connect(this, &UIThreadGroup DefinitionSave::sigComplete,1146 pChooserAbstractModel, &UIChooserAbstractModel::sltGroup DefinitionsSaveComplete);1147 } 1148 } 1149 1150 UIThreadGroup DefinitionSave::UIThreadGroupDefinitionSave()1145 connect(this, &UIThreadGroupSettingsSave::sigComplete, 1146 pChooserAbstractModel, &UIChooserAbstractModel::sltGroupSettingsSaveComplete); 1147 } 1148 } 1149 1150 UIThreadGroupSettingsSave::UIThreadGroupSettingsSave() 1151 1151 { 1152 1152 /* Assign instance: */ … … 1154 1154 } 1155 1155 1156 UIThreadGroup DefinitionSave::~UIThreadGroupDefinitionSave()1157 { 1158 /* Wait: */1156 UIThreadGroupSettingsSave::~UIThreadGroupSettingsSave() 1157 { 1158 /* Make sure thread work is complete: */ 1159 1159 wait(); 1160 1160 … … 1163 1163 } 1164 1164 1165 void UIThreadGroup DefinitionSave::run()1165 void UIThreadGroupSettingsSave::run() 1166 1166 { 1167 1167 /* COM prepare: */ … … 1185 1185 * with common cleanup in case of failure. 1186 1186 * We have to simulate a try-catch block. */ 1187 CSession session;1188 CMachine machine;1187 CSession comSession; 1188 CMachine comMachine; 1189 1189 do 1190 1190 { 1191 1191 /* 1. Open session: */ 1192 session = uiCommon().openSession(QUuid(strId));1193 if ( session.isNull())1192 comSession = uiCommon().openSession(QUuid(strId)); 1193 if (comSession.isNull()) 1194 1194 break; 1195 1195 1196 1196 /* 2. Get session machine: */ 1197 machine = session.GetMachine();1198 if ( machine.isNull())1197 comMachine = comSession.GetMachine(); 1198 if (comMachine.isNull()) 1199 1199 break; 1200 1200 1201 1201 /* 3. Set new groups: */ 1202 machine.SetGroups(newGroupList.toVector());1203 if (! machine.isOk())1202 comMachine.SetGroups(newGroupList.toVector()); 1203 if (!comMachine.isOk()) 1204 1204 { 1205 msgCenter().cannotSetGroups( machine);1205 msgCenter().cannotSetGroups(comMachine); 1206 1206 break; 1207 1207 } 1208 1208 1209 1209 /* 4. Save settings: */ 1210 machine.SaveSettings();1211 if (! machine.isOk())1210 comMachine.SaveSettings(); 1211 if (!comMachine.isOk()) 1212 1212 { 1213 msgCenter().cannotSaveMachineSettings( machine);1213 msgCenter().cannotSaveMachineSettings(comMachine); 1214 1214 break; 1215 1215 } … … 1217 1217 1218 1218 /* Cleanup if necessary: */ 1219 if ( machine.isNull() || !machine.isOk())1219 if (comMachine.isNull() || !comMachine.isOk()) 1220 1220 emit sigReload(QUuid(strId)); 1221 if (! session.isNull())1222 session.UnlockMachine();1221 if (!comSession.isNull()) 1222 comSession.UnlockMachine(); 1223 1223 } 1224 1224 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r84420 r84423 128 128 /** @name Group saving stuff. 129 129 * @{ */ 130 /** Handles group definitionsaving complete. */131 void sltGroup DefinitionsSaveComplete();130 /** Handles group settings saving complete. */ 131 void sltGroupSettingsSaveComplete(); 132 132 /** Handles group order saving complete. */ 133 133 void sltGroupOrdersSaveComplete(); … … 225 225 /** @name Group saving stuff. 226 226 * @{ */ 227 /** Saves group definitions. */228 void saveGroup Definitions();227 /** Saves group settings. */ 228 void saveGroupSettings(); 229 229 /** Saves group orders. */ 230 230 void saveGroupOrders(); 231 231 232 /** Gathers group @a definitions of @a pParentGroup. */233 void gatherGroup Definitions(QMap<QString, QStringList> &definitions, UIChooserNode *pParentGroup);232 /** Gathers group @a settings of @a pParentGroup. */ 233 void gatherGroupSettings(QMap<QString, QStringList> &settings, UIChooserNode *pParentGroup); 234 234 /** Gathers group @a orders of @a pParentGroup. */ 235 235 void gatherGroupOrders(QMap<QString, QStringList> &orders, UIChooserNode *pParentGroup); 236 236 237 /** Makes sure group definitions saving is finished. */238 void makeSureGroup DefinitionsSaveIsFinished();237 /** Makes sure group settings saving is finished. */ 238 void makeSureGroupSettingsSaveIsFinished(); 239 239 /** Makes sure group orders saving is finished. */ 240 240 void makeSureGroupOrdersSaveIsFinished(); … … 261 261 /** @name Group saving stuff. 262 262 * @{ */ 263 /** Holds the consolidated map of group definitions/orders. */263 /** Holds the consolidated map of group settings/orders. */ 264 264 QMap<QString, QStringList> m_groups; 265 265 /** @} */ … … 267 267 268 268 269 /** QThread subclass allowing to save group definitions asynchronously. */270 class UIThreadGroup DefinitionSave : public QThread269 /** QThread subclass allowing to save group settings asynchronously. */ 270 class UIThreadGroupSettingsSave : public QThread 271 271 { 272 272 Q_OBJECT; … … 282 282 public: 283 283 284 /** Returns group s aving thread instance. */285 static UIThreadGroup DefinitionSave*instance();286 /** Prepares group s aving thread instance. */284 /** Returns group settings saving thread instance. */ 285 static UIThreadGroupSettingsSave *instance(); 286 /** Prepares group settings saving thread instance. */ 287 287 static void prepare(); 288 /** Cleanups group s aving thread instance. */288 /** Cleanups group settings saving thread instance. */ 289 289 static void cleanup(); 290 290 291 /** Configures @a group s saving thread with corresponding @a pListener.292 * @param oldLists Brings the old definitionlist to be compared.293 * @param newLists Brings the new definitionlist 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. */ 294 294 void configure(QObject *pParent, 295 295 const QMap<QString, QStringList> &oldLists, … … 298 298 protected: 299 299 300 /** Constructs group s aving thread. */301 UIThreadGroup DefinitionSave();302 /** Destructs group s aving thread. */303 virtual ~UIThreadGroup DefinitionSave() /* override */;300 /** Constructs group settings saving thread. */ 301 UIThreadGroupSettingsSave(); 302 /** Destructs group settings saving thread. */ 303 virtual ~UIThreadGroupSettingsSave() /* override */; 304 304 305 305 /** Contains a thread task to be executed. */ … … 307 307 308 308 /** Holds the singleton instance. */ 309 static UIThreadGroup DefinitionSave *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. */ 312 312 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. */ 314 314 QMap<QString, QStringList> m_newLists; 315 315 };
Note:
See TracChangeset
for help on using the changeset viewer.