1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-04 09:39:42 +02:00

ScrubForwarder pushes and pops itself on the window handler stack...

... Fixing crashes on close of project window seen in some Linux builds of
2.3.3.  The bug began at commit a3b434be1cd42ff7c99821de4ea52c0945cb0baa
This commit is contained in:
Paul Licameli 2020-02-21 14:15:14 -05:00
parent d06625ba60
commit 2e314b9dd2
2 changed files with 16 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#include <wx/dcclient.h>
#include <wx/event.h>
#include <wx/windowptr.h>
///////////////////////////////////////////////////////////////////////////////
// class ScrubbingOverlay is responsible for drawing the speed numbers
@ -218,9 +219,22 @@ struct ScrubForwarder
: public wxEvtHandler
, public ClientData::Base
{
ScrubForwarder( AudacityProject &project ) : mProject{ project } {}
ScrubForwarder( AudacityProject &project )
: mProject{ project }
{
mWindow = &ProjectWindow::Get( project );
if ( mWindow )
mWindow->PushEventHandler( this );
}
~ScrubForwarder()
{
if ( mWindow )
mWindow->PopEventHandler();
}
AudacityProject &mProject;
wxWindowPtr<wxWindow> mWindow;
void OnMouse(wxMouseEvent &event);
DECLARE_EVENT_TABLE()
@ -269,9 +283,6 @@ END_EVENT_TABLE()
static const AudacityProject::AttachedObjects::RegisteredFactory sForwarderKey{
[]( AudacityProject &parent ){
auto result = std::make_shared< ScrubForwarder >( parent );
auto &window = ProjectWindow::Get( parent );
window.PushEventHandler( result.get() );
return result;
return std::make_shared< ScrubForwarder >( parent );
}
};

View File

@ -241,9 +241,6 @@ Scrubber::~Scrubber()
if (mpThread)
mpThread->Delete();
#endif
if ( mWindow )
mWindow->PopEventHandler();
}
static const auto HasWaveDataPred =