Changeset 86201 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 21, 2020 2:36:27 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp
r84610 r86201 17 17 18 18 /* Qt includes: */ 19 #include <QPointer> 19 20 #include <QTimer> 20 21 … … 40 41 , m_enmFakeCloudItemState(enmState) 41 42 , m_pTask(0) 43 , m_pEventLoop(0) 42 44 { 43 45 recache(); … … 50 52 , m_enmFakeCloudItemState(UIFakeCloudVirtualMachineItemState_NotApplicable) 51 53 , m_pTask(0) 54 , m_pEventLoop(0) 52 55 { 53 56 recache(); … … 73 76 { 74 77 QTimer::singleShot(fDelayed ? 10000 : 0, this, SLOT(sltCreateGetCloudInstanceInfoTask())); 78 } 79 80 void UIVirtualMachineItemCloud::waitForAsyncInfoUpdateFinished() 81 { 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; 75 108 } 76 109 … … 301 334 recache(); 302 335 303 /* Notify listeners finally: */ 304 emit sigStateChange(); 305 } 336 /* Exit from the event-loop if there is any: */ 337 if (m_pEventLoop) 338 m_pEventLoop->exit(); 339 /* Notify listeners otherwise: */ 340 else 341 emit sigStateChange(); 342 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h
r84610 r86201 31 31 /* Forward declarations: */ 32 32 class UITask; 33 class UITaskCloudRefreshMachineInfo; 33 34 34 35 /** UIVirtualMachineItem sub-class used as cloud Virtual Machine item interface. */ … … 74 75 /** Updates cloud VM info async way, @a fDelayed if requested or instant otherwise. */ 75 76 void updateInfoAsync(bool fDelayed); 77 /** Makes sure async info update is finished. 78 * @note This method creates own event-loop to avoid blocking calling thread event processing, 79 * so it's safe to call it from the GUI thread, ofc the method itself will be blocked. */ 80 void waitForAsyncInfoUpdateFinished(); 76 81 /** @} */ 77 82 … … 142 147 143 148 /** Holds the info acquire task instance. */ 144 UITask *m_pTask; 149 UITaskCloudRefreshMachineInfo *m_pTask; 150 /** Holds the task waiting loop instance. */ 151 QEventLoop *m_pEventLoop; 145 152 /** @} */ 146 153 };
Note:
See TracChangeset
for help on using the changeset viewer.