- Timestamp:
- Oct 25, 2021 10:26:10 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r91713 r92022 32 32 #include "UIMessageCenter.h" 33 33 #include "UIMedium.h" 34 #include "UINotificationCenter.h" 34 35 35 36 /* COM includes: */ … … 191 192 192 193 /* Create base storage for the new virtual-disk: */ 193 CProgress comProgress = newVirtualDisk.CreateBaseStorage(m_uMediumSize, mediumVariants()); 194 if (!newVirtualDisk.isOk()) 195 msgCenter().cannotCreateHardDiskStorage(newVirtualDisk, m_strMediumPath, this); 196 else 197 { 198 /* Make sure progress initially valid: */ 199 if (!comProgress.isNull() && !comProgress.GetCompleted()) 200 { 201 /* Create take snapshot progress object: */ 202 QPointer<UIProgressObject> pObject = new UIProgressObject(comProgress, this); 203 if (pObject) 204 { 205 connect(pObject.data(), &UIProgressObject::sigProgressChange, 206 this, &UIWizardNewVM::sltHandleProgressChange); 207 connect(pObject.data(), &UIProgressObject::sigProgressComplete, 208 this, &UIWizardNewVM::sltHandleProgressFinished); 209 sltHandleProgressStarted(); 210 pObject->exec(); 211 if (pObject) 212 delete pObject; 213 else 214 { 215 // Premature application shutdown, 216 // exit immediately: 217 return fResult; 218 } 219 } 220 } 221 222 /* Check for progress errors: */ 223 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 224 msgCenter().cannotCreateHardDiskStorage(comProgress, m_strMediumPath, this); 225 else 226 { 227 /* Inform UICommon about it: */ 228 uiCommon().createMedium(UIMedium(newVirtualDisk, UIMediumDeviceType_HardDisk, KMediumState_Created)); 229 230 /* Remember created virtual-disk: */ 231 m_virtualDisk = newVirtualDisk; 232 233 /* True finally: */ 234 fResult = true; 235 } 236 } 194 UINotificationProgressMediumCreate *pNotification = new UINotificationProgressMediumCreate(newVirtualDisk, 195 m_uMediumSize, 196 mediumVariants()); 197 if (!handleNotificationProgressNow(pNotification)) 198 return fResult; 199 200 /* Inform UICommon about it: */ 201 uiCommon().createMedium(UIMedium(newVirtualDisk, UIMediumDeviceType_HardDisk, KMediumState_Created)); 202 203 /* Remember created virtual-disk: */ 204 m_virtualDisk = newVirtualDisk; 205 206 /* True finally: */ 207 fResult = true; 237 208 238 209 /* Return result: */ … … 246 217 return; 247 218 248 /* Remember virtual-disk attributes: */ 249 QString strLocation = m_virtualDisk.GetLocation(); 250 if (!m_virtualDisk.isOk()) 251 { 252 msgCenter().cannotAcquireHardDiskLocation(m_virtualDisk, this); 219 /* Delete storage of existing disk: */ 220 UINotificationProgressMediumDeletingStorage *pNotification = new UINotificationProgressMediumDeletingStorage(m_virtualDisk); 221 if (!handleNotificationProgressNow(pNotification)) 253 222 return; 254 } 255 256 /* Delete storage of existing disk: */ 257 CProgress comProgress = m_virtualDisk.DeleteStorage(); 258 if (!m_virtualDisk.isOk()) 259 msgCenter().cannotDeleteHardDiskStorage(m_virtualDisk, strLocation, this); 260 else 261 { 262 /* Make sure progress initially valid: */ 263 if (!comProgress.isNull() && !comProgress.GetCompleted()) 264 { 265 /* Create take snapshot progress object: */ 266 QPointer<UIProgressObject> pObject = new UIProgressObject(comProgress, this); 267 if (pObject) 268 { 269 connect(pObject.data(), &UIProgressObject::sigProgressChange, 270 this, &UIWizardNewVM::sltHandleProgressChange); 271 connect(pObject.data(), &UIProgressObject::sigProgressComplete, 272 this, &UIWizardNewVM::sltHandleProgressFinished); 273 sltHandleProgressStarted(); 274 pObject->exec(); 275 if (pObject) 276 delete pObject; 277 else 278 { 279 // Premature application shutdown, 280 // exit immediately: 281 return; 282 } 283 } 284 } 285 286 /* Check for progress errors: */ 287 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 288 msgCenter().cannotDeleteHardDiskStorage(comProgress, strLocation, this); 289 else 290 { 291 /* Detach virtual-disk anyway: */ 292 m_virtualDisk.detach(); 293 } 294 } 223 224 /* Detach virtual-disk finally: */ 225 m_virtualDisk.detach(); 295 226 } 296 227
Note:
See TracChangeset
for help on using the changeset viewer.