Changeset 42176 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jul 17, 2012 12:23:50 PM (13 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r42133 r42176 491 491 <desc>Settings version "1.13", written by VirtualBox 4.2.x.</desc> 492 492 <!-- 493 Machine changes: tracing config; 493 Machine changes: tracing config, groups, autostart; 494 NetworkAdapter changes: unit for bandwidth group limits. 494 495 --> 495 496 </const> -
trunk/src/VBox/Main/xml/Settings.cpp
r41914 r42176 17 17 * 18 18 * Certainly ConfigFileBase::ConfigFileBase() will. Change VBOX_XML_VERSION below as well. 19 * VBOX_XML_VERSION does not have to be changed if the settings for a default VM do not 20 * touch newly introduced attributes or tags. It has the benefit that older VirtualBox 21 * versions do not trigger their "newer" code path. 19 22 * 20 23 * Once a new settings version has been added, these are the rules for introducing a new … … 323 326 else if (ulMinor == 12) 324 327 m->sv = SettingsVersion_v1_12; 325 else if (ulMinor > 12) 328 else if (ulMinor == 13) 329 m->sv = SettingsVersion_v1_13; 330 else if (ulMinor > 13) 326 331 m->sv = SettingsVersion_Future; 327 332 } … … 3224 3229 3225 3230 /** 3231 * Called for reading the <Groups> element under <Machine>. 3232 */ 3233 void MachineConfigFile::readGroups(const xml::ElementNode *pElmGroups, StringsList *pllGroups) 3234 { 3235 pllGroups->clear(); 3236 if (!pElmGroups || m->sv < SettingsVersion_v1_13) 3237 { 3238 pllGroups->push_back("/"); 3239 return; 3240 } 3241 3242 xml::NodesLoop nlGroups(*pElmGroups); 3243 const xml::ElementNode *pelmGroup; 3244 while ((pelmGroup = nlGroups.forAllNodes())) 3245 { 3246 if (pelmGroup->nameEquals("Group")) 3247 { 3248 Utf8Str strGroup; 3249 if (!pelmGroup->getAttributeValue("name", strGroup)) 3250 throw ConfigFileError(this, pelmGroup, N_("Required Group/@name attribute is missing")); 3251 pllGroups->push_back(strGroup); 3252 } 3253 } 3254 } 3255 3256 /** 3226 3257 * Called initially for the <Snapshot> element under <Machine>, if present, 3227 3258 * to store the snapshot's data into the given Snapshot structure (which is … … 3298 3329 readDebugging(elmSnapshot.findChildElement("Debugging"), &snap.debugging); 3299 3330 readAutostart(elmSnapshot.findChildElement("Autostart"), &snap.autostart); 3331 // note: Groups exist only for Machine, not for Snapshot 3300 3332 } 3301 3333 … … 3450 3482 else if (pelmMachineChild->nameEquals("Autostart")) 3451 3483 readAutostart(pelmMachineChild, &autostart); 3484 else if (pelmMachineChild->nameEquals("Groups")) 3485 readGroups(pelmMachineChild, &machineUserData.llGroups); 3452 3486 } 3453 3487 … … 4431 4465 4432 4466 /** 4467 * Creates a <Groups> node under elmParent and then writes out the XML 4468 * keys under that. Called for the <Machine> node only. 4469 * 4470 * @param pElmParent Pointer to the parent element. 4471 * @param pllGroups Pointer to the groups list. 4472 */ 4473 void MachineConfigFile::buildGroupsXML(xml::ElementNode *pElmParent, const StringsList *pllGroups) 4474 { 4475 if ( m->sv < SettingsVersion_v1_13 || pllGroups->size() == 0 4476 || (pllGroups->size() == 1 && pllGroups->front() == "/")) 4477 return; 4478 4479 xml::ElementNode *pElmGroups = pElmParent->createChild("Groups"); 4480 for (StringsList::const_iterator it = pllGroups->begin(); 4481 it != pllGroups->end(); 4482 ++it) 4483 { 4484 const Utf8Str &group = *it; 4485 xml::ElementNode *pElmGroup = pElmGroups->createChild("Group"); 4486 pElmGroup->setAttribute("name", group); 4487 } 4488 } 4489 4490 /** 4433 4491 * Writes a single snapshot into the DOM tree. Initially this gets called from MachineConfigFile::write() 4434 4492 * for the root snapshot of a machine, if present; elmParent then points to the <Snapshots> node under the … … 4461 4519 buildDebuggingXML(pelmSnapshot, &snap.debugging); 4462 4520 buildAutostartXML(pelmSnapshot, &snap.autostart); 4521 // note: Groups exist only for Machine, not for Snapshot 4463 4522 4464 4523 if (snap.llChildSnapshots.size()) … … 4610 4669 buildDebuggingXML(&elmMachine, &debugging); 4611 4670 buildAutostartXML(&elmMachine, &autostart); 4671 buildGroupsXML(&elmMachine, &machineUserData.llGroups); 4612 4672 } 4613 4673 … … 4727 4787 if (m->sv < SettingsVersion_v1_13) 4728 4788 { 4729 // VirtualBox 4.2 adds tracing and autostart.4789 // VirtualBox 4.2 adds tracing, autostart and groups. 4730 4790 if ( !debugging.areDefaultSettings() 4731 || !autostart.areDefaultSettings()) 4791 || !autostart.areDefaultSettings() 4792 || machineUserData.llGroups.size() > 1 4793 || machineUserData.llGroups.front() != "/") 4732 4794 m->sv = SettingsVersion_v1_13; 4733 4795 }
Note:
See TracChangeset
for help on using the changeset viewer.