1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-12 14:47:43 +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/dcclient.h>
#include <wx/event.h> #include <wx/event.h>
#include <wx/windowptr.h>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// class ScrubbingOverlay is responsible for drawing the speed numbers // class ScrubbingOverlay is responsible for drawing the speed numbers
@ -218,9 +219,22 @@ struct ScrubForwarder
: public wxEvtHandler : public wxEvtHandler
, public ClientData::Base , 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; AudacityProject &mProject;
wxWindowPtr<wxWindow> mWindow;
void OnMouse(wxMouseEvent &event); void OnMouse(wxMouseEvent &event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@ -269,9 +283,6 @@ END_EVENT_TABLE()
static const AudacityProject::AttachedObjects::RegisteredFactory sForwarderKey{ static const AudacityProject::AttachedObjects::RegisteredFactory sForwarderKey{
[]( AudacityProject &parent ){ []( AudacityProject &parent ){
auto result = std::make_shared< ScrubForwarder >( parent ); return std::make_shared< ScrubForwarder >( parent );
auto &window = ProjectWindow::Get( parent );
window.PushEventHandler( result.get() );
return result;
} }
}; };

View File

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