1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Fix bug 1575

Includes fix by PRL:
https://github.com/Paul-Licameli/audacity/commit/cbca44e
This commit is contained in:
Steve Daulton 2017-01-16 12:35:07 +00:00
parent e47a2ec314
commit 15aa84f10b
4 changed files with 31 additions and 17 deletions

View File

@ -1695,7 +1695,7 @@ CommandFlag AudacityProject::GetFocusedFrame()
return AlwaysEnabledFlag;
}
CommandFlag AudacityProject::GetUpdateFlags()
CommandFlag AudacityProject::GetUpdateFlags(bool checkActive)
{
// This method determines all of the flags that determine whether
// certain menu items and commands should be enabled or disabled,
@ -1703,6 +1703,16 @@ CommandFlag AudacityProject::GetUpdateFlags()
// have changed, it's not necessary to even check for updates.
auto flags = AlwaysEnabledFlag;
if (auto focus = wxWindow::FindFocus()) {
while (focus && focus->GetParent())
focus = focus->GetParent();
if (focus && !static_cast<wxTopLevelWindow*>(focus)->IsIconized())
flags |= NotMinimizedFlag;
}
if ( checkActive && !IsActive() )
return flags;
if (!gAudioIO->IsAudioTokenActive(GetAudioIOToken()))
flags |= AudioIONotBusyFlag;
else
@ -1791,8 +1801,11 @@ CommandFlag AudacityProject::GetUpdateFlags()
if (ZoomOutAvailable() && (flags & TracksExistFlag))
flags |= ZoomOutAvailableFlag;
if ((flags & LabelTracksExistFlag) && LabelTrack::IsTextClipSupported())
flags |= TextClipFlag;
// TextClipFlag is currently unused (Jan 2017, 2.1.3 alpha)
// and LabelTrack::IsTextClipSupported() is quite slow on Linux,
// so disable for now (See bug 1575).
// if ((flags & LabelTracksExistFlag) && LabelTrack::IsTextClipSupported())
// flags |= TextClipFlag;
flags |= GetFocusedFrame();
@ -1829,13 +1842,6 @@ CommandFlag AudacityProject::GetUpdateFlags()
if (bar->ControlToolBar::CanStopAudioStream())
flags |= CanStopAudioStreamFlag;
if (auto focus = wxWindow::FindFocus()) {
while (focus && focus->GetParent())
focus = focus->GetParent();
if (focus && !static_cast<wxTopLevelWindow*>(focus)->IsIconized())
flags |= NotMinimizedFlag;
}
return flags;
}
@ -1928,7 +1934,7 @@ void AudacityProject::ModifyToolbarMenus()
// checkActive is a temporary hack that should be removed as soon as we
// get multiple effect preview working
void AudacityProject::UpdateMenus(bool /*checkActive*/)
void AudacityProject::UpdateMenus(bool checkActive)
{
//ANSWER-ME: Why UpdateMenus only does active project?
//JKC: Is this test fixing a bug when multiple projects are open?
@ -1936,10 +1942,7 @@ void AudacityProject::UpdateMenus(bool /*checkActive*/)
if (this != GetActiveProject())
return;
//if (checkActive && !IsActive())
// return;
auto flags = GetUpdateFlags();
auto flags = GetUpdateFlags(checkActive);
auto flags2 = flags;
// We can enable some extra items if we have select-all-on-none.

View File

@ -38,7 +38,10 @@ void ModifyToolbarMenus();
void ModifyAllProjectToolbarMenus();
CommandFlag GetFocusedFrame();
CommandFlag GetUpdateFlags();
// If checkActive, do not do complete flags testing on an
// inactive project as it is needlessly expensive.
CommandFlag GetUpdateFlags(bool checkActive = false);
double NearestZeroCrossing(double t0);

View File

@ -1234,6 +1234,7 @@ bool ProgressDialog::Create(const wxString & title,
mStartTime = wxGetLocalTimeMillis().GetValue();
mLastUpdate = mStartTime;
mYieldTimer = mStartTime;
mCancel = false;
mStop = false;
@ -1346,7 +1347,13 @@ int ProgressDialog::Update(int value, const wxString & message)
// (and probably other things). I do not yet know why this happens and
// I'm not too keen on having timer events processed here, but you do
// what you have to do.
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT | wxEVT_CATEGORY_TIMER);
// Nyquist effects call Update on every callback, but YieldFor is
// quite slow on Linux / Mac, so don't call too frequently. (bug 1575)
if ((now - mYieldTimer > 50) || (value == 1000)) {
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT | wxEVT_CATEGORY_TIMER);
mYieldTimer = now;
}
return eProgressSuccess;
}

View File

@ -90,6 +90,7 @@ protected:
wxLongLong_t mStartTime;
wxLongLong_t mLastUpdate;
wxLongLong_t mYieldTimer;
int mLastValue; // gauge value, range = [0,1000]
bool mCancel;