1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-17 08:01:12 +02:00

RAII for locking the all-projects mutex

This commit is contained in:
Paul Licameli
2016-08-02 22:07:20 -04:00
parent cfd7648fce
commit 186679b3a6
5 changed files with 16 additions and 41 deletions

View File

@@ -295,11 +295,10 @@ void ODManager::Start()
{
mNeedsDraw=0;
wxCommandEvent event( EVT_ODTASK_UPDATE );
AudacityProject::AllProjectsDeleteLock();
ODLocker locker{ &AudacityProject::AllProjectDeleteMutex() };
AudacityProject* proj = GetActiveProject();
if(proj)
proj->GetEventHandler()->AddPendingEvent(event);
AudacityProject::AllProjectsDeleteUnlock();
}
mTerminateMutex.Lock();
}

View File

@@ -128,7 +128,7 @@ void ODTask::DoSome(float amountWork)
ODManager::Instance()->AddTask(this);
//we did a bit of progress - we should allow a resave.
AudacityProject::AllProjectsDeleteLock();
ODLocker locker{ &AudacityProject::AllProjectDeleteMutex() };
for(unsigned i=0; i<gAudacityProjects.GetCount(); i++)
{
if(IsTaskAssociatedWithProject(gAudacityProjects[i]))
@@ -138,7 +138,6 @@ void ODTask::DoSome(float amountWork)
break;
}
}
AudacityProject::AllProjectsDeleteUnlock();
// printf("%s %i is %f done\n", GetTaskName(),GetTaskNumber(),PercentComplete());
@@ -152,8 +151,8 @@ void ODTask::DoSome(float amountWork)
//END_TASK_PROFILING("On Demand open an 80 mb wav stereo file");
wxCommandEvent event( EVT_ODTASK_COMPLETE );
AudacityProject::AllProjectsDeleteLock();
ODLocker locker{ &AudacityProject::AllProjectDeleteMutex() };
for(unsigned i=0; i<gAudacityProjects.GetCount(); i++)
{
if(IsTaskAssociatedWithProject(gAudacityProjects[i]))
@@ -165,7 +164,6 @@ void ODTask::DoSome(float amountWork)
break;
}
}
AudacityProject::AllProjectsDeleteUnlock();
// printf("%s %i complete\n", GetTaskName(),GetTaskNumber());
}