MCPcopy Create free account
hub / github.com/audacity/audacity / UpdateProgress

Method UpdateProgress

libraries/lib-wx-init/ProgressDialog.cpp:1722–1831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1720}
1721
1722ProgressResult TimerProgressDialog::UpdateProgress()
1723{
1724 if (mCancel)
1725 {
1726 // for compatibility with old Update, that returned false on cancel
1727 return ProgressResult::Cancelled;
1728 }
1729 else if (mStop)
1730 {
1731 return ProgressResult::Stopped;
1732 }
1733
1734 wxLongLong_t now = wxGetUTCTimeMillis().GetValue();
1735 wxLongLong_t elapsed = now - mStartTime;
1736
1737 if (elapsed < 500)
1738 {
1739 return ProgressResult::Success;
1740 }
1741
1742 if (mIsTransparent)
1743 {
1744 SetTransparent(255);
1745 mIsTransparent = false;
1746 }
1747
1748 wxLongLong_t remains = mStartTime + mDuration - now;
1749
1750 int nGaugeValue = (1000 * elapsed) / mDuration; // range = [0,1000]
1751 // Running in TimerRecordDialog::RunWaitDialog(), for some unknown reason,
1752 // nGaugeValue here is often a little over 1000.
1753 // From testing, it's never shown bigger than 1009, but
1754 // give it a little extra, to 1010.
1755 // wxASSERT((nGaugeValue >= 0) && (nGaugeValue <= 1000)); // This ought to work.
1756 // wxASSERT((nGaugeValue >= 0) && (nGaugeValue <= 1010));
1757 //
1758 // stf. Update was being called after wxMilliSleep(<ms>), which could be up to <ms>
1759 // beyond the completion time. My guess is that the microsleep in RunWaitDialog was originally 10 ms
1760 // (same as other uses of Update) but was updated to kTimerInterval = 50 ms, thus triggering
1761 // the Assert (Bug 1367). By calling Update() before sleeping then I think nGaugeValue <= 1000 should work.
1762 wxASSERT((nGaugeValue >= 0) && (nGaugeValue <= 1000));
1763
1764 if (nGaugeValue != mLastValue)
1765 {
1766 mGauge->SetValue(nGaugeValue);
1767 mGauge->Update();
1768 mLastValue = nGaugeValue;
1769 }
1770
1771 // Only update if a full second has passed.
1772 if (now - mLastUpdate > 1000)
1773 {
1774 // Bug 1952:
1775 // wxTimeSpan will assert on ridiculously large values.
1776 // We silently wrap the displayed range at one day.
1777 // You'll only see the remaining hours, mins and secs.
1778 // With a + sign, if the time was wrapped.
1779 const wxLongLong_t wrapTime = 24 * 60 * 60 * 1000;

Callers

nothing calls this directly

Calls 5

GetActiveFunction · 0.85
GetValueMethod · 0.45
SetValueMethod · 0.45
UpdateMethod · 0.45
SetLabelMethod · 0.45

Tested by

no test coverage detected