Changeset 86207 in vbox
- Timestamp:
- Sep 21, 2020 7:49:36 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r86154 r86207 582 582 src/manager/UITaskCloudGetSettingsForm.h \ 583 583 src/manager/UITaskCloudListMachines.h \ 584 src/manager/UITaskCloudRefreshMachineInfo.h \585 584 src/manager/UIToolPaneGlobal.h \ 586 585 src/manager/UIToolPaneMachine.h \ … … 1056 1055 src/manager/UITaskCloudGetSettingsForm.cpp \ 1057 1056 src/manager/UITaskCloudListMachines.cpp \ 1058 src/manager/UITaskCloudRefreshMachineInfo.cpp \1059 1057 src/manager/UIToolPaneGlobal.cpp \ 1060 1058 src/manager/UIToolPaneMachine.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp
r86201 r86207 27 27 #include "UIIconPool.h" 28 28 #include "UIMessageCenter.h" 29 #include "UI TaskCloudRefreshMachineInfo.h"29 #include "UIProgressDialog.h" 30 30 #include "UIThreadPool.h" 31 31 #include "UIVirtualMachineItemCloud.h" … … 40 40 , m_enmMachineState(KCloudMachineState_Invalid) 41 41 , m_enmFakeCloudItemState(enmState) 42 , m_pTask(0)43 , m_pEventLoop(0)44 42 { 45 43 recache(); … … 51 49 , m_enmMachineState(KCloudMachineState_Invalid) 52 50 , m_enmFakeCloudItemState(UIFakeCloudVirtualMachineItemState_NotApplicable) 53 , m_pTask(0)54 , m_pEventLoop(0)55 51 { 56 52 recache(); … … 75 71 void UIVirtualMachineItemCloud::updateInfoAsync(bool fDelayed) 76 72 { 77 QTimer::singleShot(fDelayed ? 10000 : 0, this, SLOT(slt CreateGetCloudInstanceInfoTask()));73 QTimer::singleShot(fDelayed ? 10000 : 0, this, SLOT(sltRefreshCloudMachineInfo())); 78 74 } 79 75 80 76 void UIVirtualMachineItemCloud::waitForAsyncInfoUpdateFinished() 81 77 { 82 /* Make sure task is really created: */ 83 if (!m_pTask) 84 return; 85 86 /* Cancel the task: */ 87 m_pTask->cancel(); 88 89 /* We are creating a locally-scoped event-loop object, 90 * but holding a pointer to it for a control needs: */ 91 QEventLoop eventLoop; 92 m_pEventLoop = &eventLoop; 93 94 /* Guard ourself for the case 95 * we self-destroyed in our event-loop: */ 96 QPointer<UIVirtualMachineItemCloud> guard = this; 97 98 /* Start the blocking event-loop: */ 99 eventLoop.exec(); 100 101 /* Event-loop object unblocked, 102 * Are we still valid? */ 103 if (guard.isNull()) 104 return; 105 106 /* Cleanup the pointer finally: */ 107 m_pEventLoop = 0; 78 /* Cancel the progress-handler if any: */ 79 if (m_pProgressHandler) 80 m_pProgressHandler->cancel(); 108 81 } 109 82 … … 307 280 } 308 281 309 void UIVirtualMachineItemCloud::slt CreateGetCloudInstanceInfoTask()282 void UIVirtualMachineItemCloud::sltRefreshCloudMachineInfo() 310 283 { 311 284 /* Make sure item is of real cloud type and is initialized: */ 312 285 AssertReturnVoid(itemType() == UIVirtualMachineItemType_CloudReal); 313 286 314 /* Create and start task to refresh info async way only if there is no task yet: */ 315 if (!m_pTask) 287 /* Ignore refresh request if there is progress already: */ 288 if (m_pProgressHandler) 289 return; 290 291 /* Create 'Refresh' progress: */ 292 m_comProgress = m_comCloudMachine.Refresh(); 293 if (!m_comCloudMachine.isOk()) 294 msgCenter().cannotAcquireCloudMachineParameter(m_comCloudMachine); 295 else 316 296 { 317 m_pTask = new UITaskCloudRefreshMachineInfo(m_comCloudMachine); 318 connect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete, 319 this, &UIVirtualMachineItemCloud::sltHandleRefreshCloudMachineInfoDone); 320 uiCommon().threadPoolCloud()->enqueueTask(m_pTask); 297 /* Prepare 'Refresh' progress handler: */ 298 m_pProgressHandler = new UIProgress(m_comProgress, this); 299 if (m_pProgressHandler) 300 connect(m_pProgressHandler, &UIProgress::sigProgressComplete, 301 this, &UIVirtualMachineItemCloud::sltHandleRefreshCloudMachineInfoDone); 321 302 } 322 303 } 323 304 324 void UIVirtualMachineItemCloud::sltHandleRefreshCloudMachineInfoDone(UITask *pTask) 325 { 326 /* Skip unrelated tasks: */ 327 if (!m_pTask || pTask != m_pTask) 328 return; 329 330 /* Mark our task handled: */ 331 m_pTask = 0; 305 void UIVirtualMachineItemCloud::sltHandleRefreshCloudMachineInfoDone() 306 { 307 /* If not canceled => check progress result: */ 308 if ( !m_comProgress.GetCanceled() 309 && (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0)) 310 msgCenter().cannotAcquireCloudMachineParameter(m_comProgress); 332 311 333 312 /* Recache: */ 334 313 recache(); 335 314 336 /* Exit from the event-loop if there is any: */ 337 if (m_pEventLoop) 338 m_pEventLoop->exit(); 339 /* Notify listeners otherwise: */ 340 else 315 /* If not canceled => notify listeners: */ 316 if (!m_comProgress.GetCanceled()) 341 317 emit sigStateChange(); 342 } 318 319 /* Cleanup the handler and the progress: */ 320 delete m_pProgressHandler; 321 m_pProgressHandler = 0; 322 m_comProgress = CProgress(); 323 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h
r86201 r86207 22 22 #endif 23 23 24 /* Qt includes: */ 25 #include <QPointer> 26 24 27 /* GUI includes: */ 25 28 #include "UIVirtualMachineItem.h" … … 28 31 #include "COMEnums.h" 29 32 #include "CCloudMachine.h" 33 #include "CProgress.h" 30 34 31 35 /* Forward declarations: */ 32 class UITask; 33 class UITaskCloudRefreshMachineInfo; 36 class UIProgress; 34 37 35 38 /** UIVirtualMachineItem sub-class used as cloud Virtual Machine item interface. */ … … 123 126 private slots: 124 127 125 /** Create cloud VM info acquire task. */126 void slt CreateGetCloudInstanceInfoTask();127 /** Handles signal about cloud VM info refresh taskis done. */128 void sltHandleRefreshCloudMachineInfoDone( UITask *pTask);128 /** Starts cloud VM info refresh progress. */ 129 void sltRefreshCloudMachineInfo(); 130 /** Handles signal about cloud VM info refresh progress is done. */ 131 void sltHandleRefreshCloudMachineInfoDone(); 129 132 130 133 private: … … 146 149 QString m_strFakeCloudItemErrorMessage; 147 150 148 /** Holds the info acquire taskinstance. */149 UITaskCloudRefreshMachineInfo *m_pTask;150 /** Holds the task waiting loopinstance. */151 Q EventLoop *m_pEventLoop;151 /** Holds the machine refresh progress object instance. */ 152 CProgress m_comProgress; 153 /** Holds the machine refresh progress handler instance. */ 154 QPointer<UIProgress> m_pProgressHandler; 152 155 /** @} */ 153 156 };
Note:
See TracChangeset
for help on using the changeset viewer.