1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 23:33:49 +01:00

Fix other cause of intermittent timing-dependent crash at shutdown...

... AudioIO holds a weak pointer to its listener so there is no dangling
pointer
This commit is contained in:
Paul Licameli
2019-06-24 13:32:08 -04:00
parent b8838b38ed
commit e08a942ab8
6 changed files with 48 additions and 34 deletions

View File

@@ -383,7 +383,8 @@ AudacityProject *ProjectManager::New()
//Initialise the Listeners
auto gAudioIO = AudioIO::Get();
gAudioIO->SetListener( &ProjectAudioManager::Get( project ) );
gAudioIO->SetListener(
ProjectAudioManager::Get( project ).shared_from_this() );
auto &projectSelectionManager = ProjectSelectionManager::Get( project );
SelectionBar::Get( project ).SetListener( &projectSelectionManager );
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
@@ -599,10 +600,14 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
// Since we're going to be destroyed, make sure we're not to
// receive audio notifications anymore.
if ( gAudioIO->GetListener() == &ProjectAudioManager::Get( project ) ) {
// PRL: Maybe all this is unnecessary now that the listener is managed
// by a weak pointer.
if ( gAudioIO->GetListener().get() == &ProjectAudioManager::Get( project ) ) {
auto active = GetActiveProject();
gAudioIO->SetListener(
active ? &ProjectAudioManager::Get( *active ) : nullptr
active
? ProjectAudioManager::Get( *active ).shared_from_this()
: nullptr
);
}