- Timestamp:
- Nov 19, 2013 5:41:16 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 90750
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.cpp
r48608 r49557 80 80 m_result = other.result(); 81 81 82 m_strKey = other.key(); 82 83 m_strId = other.id(); 83 84 m_strName = other.name(); … … 168 169 169 170 m_strId = m_medium.isNull() ? nullID() : m_medium.GetId(); 171 172 if (m_strKey.isNull() && !m_strId.isNull()) 173 m_strKey = m_strId; 170 174 171 175 m_fHostDrive = m_medium.isNull() ? false : m_medium.GetHostDrive(); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.h
r48301 r49557 138 138 } 139 139 140 QString key() const { return m_strKey; } 141 void setKey(const QString &strKey) { m_strKey = strKey; } 142 140 143 QString id() const { return m_strId; } 141 144 QString name(bool fNoDiffs = false) const { return fNoDiffs ? root().m_strName : m_strName; } … … 233 236 COMResult m_result; 234 237 238 QString m_strKey; 235 239 QString m_strId; 236 240 QString m_strName; -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.cpp
r49553 r49557 107 107 { 108 108 /* Get medium ID: */ 109 QString strMediumID = medium.id(); 110 LogRelFlow(("UIMediumEnumerator: Medium with ID={%s} created.\n", strMediumID.toAscii().constData())); 111 109 const QString strMediumID = medium.id(); 110 111 /* Do not create UIMedium(s) with incorrect ID: */ 112 AssertReturnVoid(!strMediumID.isNull()); 113 AssertReturnVoid(strMediumID != UIMedium::nullID()); 112 114 /* Make sure medium doesn't exists already: */ 113 115 AssertReturnVoid(!m_mediums.contains(strMediumID)); … … 115 117 /* Insert medium: */ 116 118 m_mediums[strMediumID] = medium; 119 LogRel(("UIMediumEnumerator: Medium with key={%s} created.\n", strMediumID.toAscii().constData())); 117 120 118 121 /* Notify listener: */ … … 122 125 void UIMediumEnumerator::deleteMedium(const QString &strMediumID) 123 126 { 124 LogRelFlow(("UIMediumEnumerator: Medium with ID={%s} removed.\n", strMediumID.toAscii().constData())); 125 127 /* Do not delete UIMedium(s) with incorrect ID: */ 128 AssertReturnVoid(!strMediumID.isNull()); 129 AssertReturnVoid(strMediumID != UIMedium::nullID()); 126 130 /* Make sure medium still exists: */ 127 131 AssertReturnVoid(m_mediums.contains(strMediumID)); … … 129 133 /* Remove medium: */ 130 134 m_mediums.remove(strMediumID); 135 LogRel(("UIMediumEnumerator: Medium with key={%s} deleted.\n", strMediumID.toAscii().constData())); 131 136 132 137 /* Notify listener: */ … … 153 158 154 159 /* Notify listener: */ 155 LogRel Flow(("UIMediumEnumerator: Medium-enumeration started...\n"));160 LogRel(("UIMediumEnumerator: Medium-enumeration started...\n")); 156 161 m_fMediumEnumerationInProgress = true; 157 162 emit sigMediumEnumerationStarted(); 158 163 159 /* Start enumeration for all the new mediums: */164 /* Start enumeration for UIMedium(s) with correct ID: */ 160 165 foreach (const QString &strMediumID, m_mediums.keys()) 161 createMediumEnumerationTask(m_mediums[strMediumID]); 166 if (!strMediumID.isNull() && strMediumID != UIMedium::nullID()) 167 createMediumEnumerationTask(m_mediums[strMediumID]); 162 168 } 163 169 164 170 void UIMediumEnumerator::sltHandleMachineUpdate(QString strMachineID) 165 171 { 166 LogRel Flow(("UIMediumEnumerator: Machine event received, ID = %s\n", strMachineID.toAscii().constData()));172 LogRel(("UIMediumEnumerator: Machine event received, ID = %s\n", strMachineID.toAscii().constData())); 167 173 168 174 /* Compose a map of previous usage: */ … … 175 181 oldUsage << strMediumID; 176 182 } 177 LogRel Flow(("UIMediumEnumerator: Old usage: %s\n", oldUsage.isEmpty() ? "<empty>" : oldUsage.join(", ").toAscii().constData()));183 LogRel(("UIMediumEnumerator: Old usage: %s\n", oldUsage.isEmpty() ? "<empty>" : oldUsage.join(", ").toAscii().constData())); 178 184 179 185 /* Compose a map of current usage: */ … … 193 199 } 194 200 } 195 LogRel Flow(("UIMediumEnumerator: New usage: %s\n", newUsage.isEmpty() ? "<empty>" : newUsage.join(", ").toAscii().constData()));201 LogRel(("UIMediumEnumerator: New usage: %s\n", newUsage.isEmpty() ? "<empty>" : newUsage.join(", ").toAscii().constData())); 196 202 197 203 /* Manipulations over the sets: */ … … 203 209 QStringList includedList = includedSet.toList(); 204 210 if (!excludedList.isEmpty()) 205 LogRel Flow(("UIMediumEnumerator: Items excluded from machine usage: %s\n", excludedList.join(", ").toAscii().constData()));211 LogRel(("UIMediumEnumerator: Items excluded from machine usage: %s\n", excludedList.join(", ").toAscii().constData())); 206 212 if (!includedList.isEmpty()) 207 LogRel Flow(("UIMediumEnumerator: Items included into machine usage: %s\n", includedList.join(", ").toAscii().constData()));213 LogRel(("UIMediumEnumerator: Items included into machine usage: %s\n", includedList.join(", ").toAscii().constData())); 208 214 209 215 /* For each of excluded items: */ 210 foreach (const QString &strExcludedMedium ID, excludedList)216 foreach (const QString &strExcludedMediumKey, excludedList) 211 217 { 212 218 /* Make sure this medium still in our map: */ 213 if (!m_mediums.contains(strExcludedMedium ID))219 if (!m_mediums.contains(strExcludedMediumKey)) 214 220 continue; 215 /* Remove UIMedium if it was closed already: */ 216 const UIMedium &uimedium = m_mediums[strExcludedMediumID]; 217 if (uimedium.medium().GetId() != strExcludedMediumID) 221 222 /* Get excluded UIMedium: */ 223 const UIMedium &uimedium = m_mediums[strExcludedMediumKey]; 224 225 /* Delete UIMedium if CMedium was closed already: */ 226 CMedium cmedium = uimedium.medium(); 227 if (cmedium.GetId().isNull() || !cmedium.isOk()) 218 228 { 219 deleteMedium(strExcludedMediumID); 229 /* Delete this medium: */ 230 m_mediums.remove(strExcludedMediumKey); 231 LogRel(("UIMediumEnumerator: Medium with key={%s} closed and deleted (before enumeration).\n", strExcludedMediumKey.toAscii().constData())); 232 /* And notify listener about delete: */ 233 emit sigMediumDeleted(strExcludedMediumKey); 220 234 continue; 221 235 } 236 222 237 /* Enumerate UIMedium if CMedium still exists: */ 223 238 createMediumEnumerationTask(uimedium); … … 234 249 createMedium(uimedium); 235 250 } 251 236 252 /* Enumerate UIMedium in any case: */ 237 253 createMediumEnumerationTask(m_mediums[strIncludedMediumID]); 238 254 } 239 255 240 LogRel Flow(("UIMediumEnumerator: Machine event processed, ID = %s\n", strMachineID.toAscii().constData()));256 LogRel(("UIMediumEnumerator: Machine event processed, ID = %s\n", strMachineID.toAscii().constData())); 241 257 } 242 258 … … 247 263 AssertReturnVoid(iIndexOfTask != -1); 248 264 249 /* Get medium: */250 UIMediummedium = pTask->data().value<UIMedium>();251 QString strMediumID = medium.id();252 LogRel Flow(("UIMediumEnumerator: Medium with ID={%s} enumerated.\n", strMediumID.toAscii().constData()));265 /* Get enumerated UIMedium: */ 266 const UIMedium uimedium = pTask->data().value<UIMedium>(); 267 const QString strUIMediumKey = uimedium.key(); 268 LogRel2(("UIMediumEnumerator: Medium with key={%s} enumerated.\n", strUIMediumKey.toAscii().constData())); 253 269 254 270 /* Delete task: */ 255 271 delete m_tasks.takeAt(iIndexOfTask); 256 272 257 /* Make sure such medium still exists: */ 258 if (!m_mediums.contains(strMediumID)) 259 return; 260 261 /* Update enumerated medium: */ 262 m_mediums[strMediumID] = medium; 263 264 /* Notify listener: */ 265 emit sigMediumEnumerated(strMediumID); 273 /* Make sure such UIMedium still exists: */ 274 AssertReturnVoid(m_mediums.contains(strUIMediumKey)); 275 276 /* Check if UIMedium ID was changed: */ 277 const QString strUIMediumID = uimedium.id(); 278 /* UIMedium ID was changed to null string: */ 279 if (strUIMediumID.isNull()) 280 { 281 /* Delete this medium: */ 282 m_mediums.remove(strUIMediumKey); 283 LogRel(("UIMediumEnumerator: Medium with key={%s} closed and deleted (after enumeration).\n", strUIMediumKey.toAscii().constData())); 284 /* And notify listener about delete: */ 285 emit sigMediumDeleted(strUIMediumKey); 286 } 287 /* UIMedium ID was changed to something proper: */ 288 else if (strUIMediumID != strUIMediumKey) 289 { 290 /* We have to reinject enumerated medium: */ 291 m_mediums.remove(strUIMediumKey); 292 m_mediums[strUIMediumID] = uimedium; 293 m_mediums[strUIMediumID].setKey(strUIMediumID); 294 LogRel(("UIMediumEnumerator: Medium with key={%s} has it changed to {%s}.\n", strUIMediumKey.toAscii().constData(), 295 strUIMediumID.toAscii().constData())); 296 297 /* And notify listener about delete/create: */ 298 emit sigMediumDeleted(strUIMediumKey); 299 emit sigMediumCreated(strUIMediumID); 300 } 301 /* UIMedium ID was not changed: */ 302 else 303 { 304 /* Just update enumerated medium: */ 305 m_mediums[strUIMediumID] = uimedium; 306 LogRel2(("UIMediumEnumerator: Medium with key={%s} updated.\n", strUIMediumID.toAscii().constData())); 307 308 /* And notify listener about update: */ 309 emit sigMediumEnumerated(strUIMediumID); 310 } 266 311 267 312 /* If there are no more tasks we know about: */ … … 269 314 { 270 315 /* Notify listener: */ 271 LogRel Flow(("UIMediumEnumerator: Medium-enumeration finished!\n"));316 LogRel(("UIMediumEnumerator: Medium-enumeration finished!\n")); 272 317 m_fMediumEnumerationInProgress = false; 273 318 emit sigMediumEnumerationFinished();
Note:
See TracChangeset
for help on using the changeset viewer.