VirtualBox

Changeset 69005 in vbox


Ignore:
Timestamp:
Oct 6, 2017 2:37:28 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8674: A bit of rework for UIProgressDialog (part 5): Protect agains early finished or aborted progress (required for event handling only).

File:
1 edited

Legend:

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

    r69004 r69005  
    9090int UIProgressDialog::run(int cRefreshInterval)
    9191{
    92     if (m_comProgress.isOk())
    93     {
    94         /* Start refresh timer: */
    95         int id = startTimer(cRefreshInterval);
    96 
    97         /* Set busy cursor.
    98          * We don't do this on the Mac, cause regarding the design rules of
    99          * Apple there is no busy window behavior. A window should always be
    100          * responsive and it is in our case (We show the progress dialog bar). */
     92    /* Make sure progress hasn't finished already: */
     93    if (!m_comProgress.isOk() || m_comProgress.GetCompleted())
     94    {
     95        /* Progress completed? */
     96        if (m_comProgress.isOk())
     97            return Accepted;
     98        /* Or aborted? */
     99        else
     100            return Rejected;
     101    }
     102
     103    /* Start refresh timer: */
     104    int id = startTimer(cRefreshInterval);
     105
     106    /* Set busy cursor.
     107     * We don't do this on the Mac, cause regarding the design rules of
     108     * Apple there is no busy window behavior. A window should always be
     109     * responsive and it is in our case (We show the progress dialog bar). */
    101110#ifndef VBOX_WS_MAC
    102         if (m_fCancelEnabled)
    103             QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
    104         else
    105             QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     111    if (m_fCancelEnabled)
     112        QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
     113    else
     114        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    106115#endif /* VBOX_WS_MAC */
    107116
    108         /* Create a local event-loop: */
    109         {
    110             /* Guard ourself for the case
    111              * we destroyed ourself in our event-loop: */
    112             QPointer<UIProgressDialog> guard = this;
    113 
    114             /* Holds the modal loop, but don't show the window immediately: */
    115             execute(false);
    116 
    117             /* Are we still valid? */
    118             if (guard.isNull())
    119                 return Rejected;
    120         }
    121 
    122         /* Kill refresh timer: */
    123         killTimer(id);
     117    /* Create a local event-loop: */
     118    {
     119        /* Guard ourself for the case
     120         * we destroyed ourself in our event-loop: */
     121        QPointer<UIProgressDialog> guard = this;
     122
     123        /* Holds the modal loop, but don't show the window immediately: */
     124        execute(false);
     125
     126        /* Are we still valid? */
     127        if (guard.isNull())
     128            return Rejected;
     129    }
     130
     131    /* Kill refresh timer: */
     132    killTimer(id);
    124133
    125134#ifndef VBOX_WS_MAC
    126         /* Reset the busy cursor */
    127         QApplication::restoreOverrideCursor();
     135    /* Reset the busy cursor */
     136    QApplication::restoreOverrideCursor();
    128137#endif /* VBOX_WS_MAC */
    129138
    130         return result();
    131     }
    132     return Rejected;
     139    return result();
    133140}
    134141
     
    440447    {
    441448        /* Set progress to 100%: */
    442         m_pProgressBar->setValue(100);
     449        updateProgressPercentage(100);
    443450
    444451        /* Try to close the dialog: */
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