VirtualBox

Changeset 86206 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 21, 2020 7:41:18 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: Extend UIProgress with possibilities to cancel ongoing progress the modal way and a signal notifying listeners about ongoing progress is complete.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp

    r86205 r86206  
    588588}
    589589
     590void UIProgress::cancel()
     591{
     592    /* Make sure progress hasn't aborted/finished already: */
     593    if (!m_comProgress.isOk() || m_comProgress.GetCompleted())
     594        return;
     595
     596    /* Cancel progress first of all: */
     597    m_comProgress.Cancel();
     598
     599    /* We are creating a locally-scoped event-loop object,
     600     * but holding a pointer to it for a control needs: */
     601    QEventLoop eventLoop;
     602    m_pEventLoopCancel = &eventLoop;
     603
     604    /* Guard ourself for the case
     605     * we self-destroyed in our event-loop: */
     606    QPointer<UIProgress> guard = this;
     607
     608    /* Start the blocking event-loop: */
     609    eventLoop.exec();
     610
     611    /* Event-loop object unblocked,
     612     * Are we still valid? */
     613    if (guard.isNull())
     614        return;
     615
     616    /* Cleanup the pointer finally: */
     617    m_pEventLoopCancel = 0;
     618}
     619
    590620void UIProgress::sltHandleProgressPercentageChange(const QUuid &, const int iPercent)
    591621{
     
    605635    if (m_pEventLoopExec)
    606636        m_pEventLoopExec->exit();
     637    /* Exit from the cancel event-loop if there is any: */
     638    if (m_pEventLoopCancel)
     639        m_pEventLoopCancel->exit();
     640
     641    emit sigProgressComplete();
    607642}
    608643
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.h

    r86205 r86206  
    194194    void sigProgressError(QString strErrorInfo);
    195195
     196    /** Notifies listeners about wrapped CProgress complete. */
     197    void sigProgressComplete();
     198
    196199public:
    197200
     
    204207    /** Executes the progress within local event-loop. */
    205208    void exec();
     209    /** Cancels the progress within local event-loop. */
     210    void cancel();
    206211
    207212private slots:
     
    231236    /** Holds the exec event-loop instance. */
    232237    QPointer<QEventLoop>  m_pEventLoopExec;
     238    /** Holds the cancel event-loop instance. */
     239    QPointer<QEventLoop>  m_pEventLoopCancel;
    233240};
    234241
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