VirtualBox

Ignore:
Timestamp:
Oct 15, 2021 9:45:40 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Extend UINotificationCenter with possibility to handle progresses synchronously; Convey that functionality to UINativeWizard so that it could handle intermediate progresses that way.

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  
    225225    AssertReturnVoid(!uId.isNull());
    226226    return m_pModel->revokeObject(uId);
     227}
     228
     229void 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;
    227262}
    228263
     
    361396}
    362397
     398void 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
    363407void UINotificationCenter::prepare()
    364408{
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.h

    r91753 r91755  
    2323
    2424/* Qt includes: */
     25#include <QEventLoop>
     26#include <QPointer>
    2527#include <QUuid>
    2628#include <QWidget>
     
    7981    void revoke(const QUuid &uId);
    8082
     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
    8187protected:
    8288
     
    105111    /** Handles signal about model being updated. */
    106112    void sltModelChanged();
     113
     114    /** Handles immediate progress being finished.
     115      * @note Breaks blocking handleNow() call. */
     116    void sltHandleProgressFinished();
    107117
    108118private:
     
    160170    /** Holds the open-object ID. */
    161171    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;
    162177};
    163178
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.cpp

    r91754 r91755  
    7979#endif /* VBOX_WS_MAC */
    8080
     81
     82void UINativeWizard::handleNotificationProgressNow(UINotificationProgress *pProgress)
     83{
     84    m_pNotificationCenter->handleNow(pProgress);
     85}
    8186
    8287int UINativeWizard::exec()
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.h

    r91754 r91755  
    3939class UINativeWizardPage;
    4040class UINotificationCenter;
     41class UINotificationProgress;
    4142
    4243/** Native wizard buttons. */
     
    7677{
    7778    Q_OBJECT;
     79
     80public:
     81
     82    /** Immediately handles notification @a pProgress object. */
     83    void handleNotificationProgressNow(UINotificationProgress *pProgress);
    7884
    7985public slots:
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette