Changeset 91755 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 15, 2021 9:45:40 AM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.cpp
r91753 r91755 225 225 AssertReturnVoid(!uId.isNull()); 226 226 return m_pModel->revokeObject(uId); 227 } 228 229 void UINotificationCenter::handleNow(UINotificationProgress *pProgress) 230 { 231 /* Check for the recursive run: */ 232 AssertMsgReturnVoid(!m_pEventLoop, ("UINotificationCenter::handleNow() is called recursively!\n")); 233 234 /* Guard progress for the case 235 * it destroyed itself in his append call: */ 236 QPointer<UINotificationProgress> guardProgress = pProgress; 237 connect(pProgress, &UINotificationProgress::sigProgressFinished, 238 this, &UINotificationCenter::sltHandleProgressFinished); 239 append(pProgress); 240 241 /* Is progress still valid? */ 242 if (guardProgress.isNull()) 243 return; 244 245 /* Create a local event-loop: */ 246 QEventLoop eventLoop; 247 m_pEventLoop = &eventLoop; 248 249 /* Guard ourself for the case 250 * we destroyed ourself in our event-loop: */ 251 QPointer<UINotificationCenter> guardThis = this; 252 253 /* Start the blocking event-loop: */ 254 eventLoop.exec(); 255 256 /* Are we still valid? */ 257 if (guardThis.isNull()) 258 return; 259 260 /* Cleanup event-loop: */ 261 m_pEventLoop = 0; 227 262 } 228 263 … … 361 396 } 362 397 398 void UINotificationCenter::sltHandleProgressFinished() 399 { 400 /* Make sure event-loop is running: */ 401 AssertPtrReturnVoid(m_pEventLoop.data()); 402 403 /* Break the loop: */ 404 m_pEventLoop->exit(); 405 } 406 363 407 void UINotificationCenter::prepare() 364 408 { -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.h
r91753 r91755 23 23 24 24 /* Qt includes: */ 25 #include <QEventLoop> 26 #include <QPointer> 25 27 #include <QUuid> 26 28 #include <QWidget> … … 79 81 void revoke(const QUuid &uId); 80 82 83 /** Immediately and synchronously handles passed notification @a pProgress. 84 * @note It's a blocking call finished by sltHandleProgressFinished(). */ 85 void handleNow(UINotificationProgress *pProgress); 86 81 87 protected: 82 88 … … 105 111 /** Handles signal about model being updated. */ 106 112 void sltModelChanged(); 113 114 /** Handles immediate progress being finished. 115 * @note Breaks blocking handleNow() call. */ 116 void sltHandleProgressFinished(); 107 117 108 118 private: … … 160 170 /** Holds the open-object ID. */ 161 171 QUuid m_uOpenObjectId; 172 173 /** Holds the separate event-loop instance. 174 * @note This event-loop is only used when the center 175 * handles progress directly via handleNow(). */ 176 QPointer<QEventLoop> m_pEventLoop; 162 177 }; 163 178 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.cpp
r91754 r91755 79 79 #endif /* VBOX_WS_MAC */ 80 80 81 82 void UINativeWizard::handleNotificationProgressNow(UINotificationProgress *pProgress) 83 { 84 m_pNotificationCenter->handleNow(pProgress); 85 } 81 86 82 87 int UINativeWizard::exec() -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.h
r91754 r91755 39 39 class UINativeWizardPage; 40 40 class UINotificationCenter; 41 class UINotificationProgress; 41 42 42 43 /** Native wizard buttons. */ … … 76 77 { 77 78 Q_OBJECT; 79 80 public: 81 82 /** Immediately handles notification @a pProgress object. */ 83 void handleNotificationProgressNow(UINotificationProgress *pProgress); 78 84 79 85 public slots:
Note:
See TracChangeset
for help on using the changeset viewer.