From bf5228267ab38d0b376243d92827fe8cf39b5f04 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 31 Jan 2018 10:08:42 -0500 Subject: [PATCH 1/4] Calls to Disconnect or Unbind in destructors are not needed, if... ... it's either the source of the connection that is being destroyed, or other object (such as an ancestor window) transitively owning it and so causing it to be destroyed too; or, the sink is being destroyed, and that sink is a wxEvtHandler (which is always so for Disconnect, though not for Unbind in case Bind was passed a member function of a non-wxEvtHandler). wxWidgets takes care of erasing the connection in such cases. This removes most calls to Disconnect and Unbind. Many destructors shrank to nothing. Notably, in case of popup menu handling, the call to Disconnect is not removable because the object being destroyed is neither the source nor the sink. --- src/AudacityLogger.cpp | 51 +------------------------- src/AudacityLogger.h | 2 - src/HistoryWindow.cpp | 15 -------- src/HistoryWindow.h | 1 - src/LyricsWindow.cpp | 8 ---- src/LyricsWindow.h | 1 - src/MixerBoard.cpp | 11 ------ src/MixerBoard.h | 1 - src/PluginManager.cpp | 9 ----- src/Project.cpp | 18 --------- src/Project.h | 1 - src/Track.cpp | 2 +- src/TrackPanel.cpp | 14 ------- src/TranslatableStringArray.h | 9 ----- src/effects/Contrast.cpp | 8 ---- src/effects/Contrast.h | 1 - src/effects/Effect.cpp | 10 ----- src/prefs/KeyConfigPrefs.cpp | 31 ---------------- src/prefs/KeyConfigPrefs.h | 1 - src/toolbars/ToolManager.cpp | 24 ------------ src/tracks/ui/PlayIndicatorOverlay.cpp | 5 --- src/tracks/ui/Scrubbing.cpp | 12 ------ src/tracks/ui/Scrubbing.h | 1 - src/tracks/ui/SelectHandle.cpp | 9 ----- src/widgets/Meter.cpp | 29 --------------- src/widgets/Meter.h | 2 - src/widgets/PopupMenuTable.cpp | 2 + src/widgets/Ruler.cpp | 5 --- src/widgets/wxPanelWrapper.h | 5 --- 29 files changed, 4 insertions(+), 284 deletions(-) diff --git a/src/AudacityLogger.cpp b/src/AudacityLogger.cpp index 70d045958..0124cdbcc 100644 --- a/src/AudacityLogger.cpp +++ b/src/AudacityLogger.cpp @@ -57,11 +57,6 @@ AudacityLogger::AudacityLogger() mUpdated = false; } -AudacityLogger::~AudacityLogger() -{ - Destroy(); -} - void AudacityLogger::Flush() { if (mUpdated && mFrame && mFrame->IsShown()) { @@ -95,50 +90,6 @@ void AudacityLogger::DoLogText(const wxString & str) } } -void AudacityLogger::Destroy() -{ - if (mFrame) { - mFrame->Disconnect(LoggerID_Save, - wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(AudacityLogger::OnSave), - NULL, - this); - mFrame->Disconnect(LoggerID_Clear, - wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(AudacityLogger::OnClear), - NULL, - this); - mFrame->Disconnect(LoggerID_Close, - wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(AudacityLogger::OnClose), - NULL, - this); - - mFrame->Disconnect(LoggerID_Save, - wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AudacityLogger::OnSave), - NULL, - this); - mFrame->Disconnect(LoggerID_Clear, - wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AudacityLogger::OnClear), - NULL, - this); - mFrame->Disconnect(LoggerID_Close, - wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AudacityLogger::OnClose), - NULL, - this); - - mFrame->Disconnect(wxEVT_CLOSE_WINDOW, - wxCloseEventHandler(AudacityLogger::OnCloseWindow), - NULL, - this); - - mFrame.reset(); - } -} - void AudacityLogger::Show(bool show) { // Hide the frame if created, otherwise do nothing @@ -272,7 +223,7 @@ void AudacityLogger::OnCloseWindow(wxCloseEvent & WXUNUSED(e)) // On the Mac, destroy the window rather than hiding it since the // log menu will override the root windows menu if there is no // project window open. - Destroy(); + mFrame.reset(); #else Show(false); #endif diff --git a/src/AudacityLogger.h b/src/AudacityLogger.h index 473460d94..407e8f58f 100644 --- a/src/AudacityLogger.h +++ b/src/AudacityLogger.h @@ -28,10 +28,8 @@ class AudacityLogger final : public wxEvtHandler, public wxLog { public: AudacityLogger(); - virtual ~AudacityLogger(); void Show(bool show = true); - void Destroy(); #if defined(EXPERIMENTAL_CRASH_REPORT) wxString GetLog(); diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 016b6dcc1..1a8eb328b 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -152,21 +152,6 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): this); } -HistoryWindow::~HistoryWindow() -{ - wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(HistoryWindow::OnAudioIO), - NULL, - this); - - wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(HistoryWindow::OnAudioIO), - NULL, - this); - - mAvail->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); -} - void HistoryWindow::OnAudioIO(wxCommandEvent& evt) { evt.Skip(); diff --git a/src/HistoryWindow.h b/src/HistoryWindow.h index 7d4df5eb0..c7cd68d2c 100644 --- a/src/HistoryWindow.h +++ b/src/HistoryWindow.h @@ -28,7 +28,6 @@ class HistoryWindow final : public wxDialogWrapper { public: HistoryWindow(AudacityProject * parent, UndoManager *manager); - ~HistoryWindow(); void UpdateDisplay(); diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index a5b27a624..527d64c64 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -133,14 +133,6 @@ LyricsWindow::LyricsWindow(AudacityProject *parent): Center(); } -LyricsWindow::~LyricsWindow() -{ - mProject->Disconnect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(LyricsWindow::OnTimer), - NULL, - this); -} - void LyricsWindow::OnCloseWindow(wxCloseEvent & WXUNUSED(event)) { this->Hide(); diff --git a/src/LyricsWindow.h b/src/LyricsWindow.h index 0c640f851..f39ba6cbe 100644 --- a/src/LyricsWindow.h +++ b/src/LyricsWindow.h @@ -23,7 +23,6 @@ class LyricsWindow final : public wxFrame { public: LyricsWindow(AudacityProject* parent); - virtual ~LyricsWindow(); LyricsPanel *GetLyricsPanel() { return mLyricsPanel; }; diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 37e726106..ea3a86bc2 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -934,17 +934,6 @@ MixerBoard::MixerBoard(AudacityProject* pProject, this); } -MixerBoard::~MixerBoard() -{ - // private data members - mMusicalInstruments.clear(); - - mProject->Disconnect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(MixerBoard::OnTimer), - NULL, - this); -} - diff --git a/src/MixerBoard.h b/src/MixerBoard.h index 1f77eab3c..c5a7859a1 100644 --- a/src/MixerBoard.h +++ b/src/MixerBoard.h @@ -206,7 +206,6 @@ public: wxFrame* parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - virtual ~MixerBoard(); void UpdatePrefs(); diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 62c8a3742..d2616de73 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -423,7 +423,6 @@ class PluginRegistrationDialog final : public wxDialogWrapper public: // constructors and destructors PluginRegistrationDialog(wxWindow *parent, EffectType type); - virtual ~PluginRegistrationDialog(); private: void Populate(); @@ -501,14 +500,6 @@ PluginRegistrationDialog::PluginRegistrationDialog(wxWindow *parent, EffectType Populate(); } -PluginRegistrationDialog::~PluginRegistrationDialog() -{ - mEffects->Disconnect(wxEVT_KEY_DOWN, - wxKeyEventHandler(PluginRegistrationDialog::OnListChar), - NULL, - this); -} - void PluginRegistrationDialog::Populate() { //------------------------- Main section -------------------- diff --git a/src/Project.cpp b/src/Project.cpp index db0eaa14e..c77e09862 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -1258,11 +1258,6 @@ AudacityProject::~AudacityProject() mTrackPanel->RemoveOverlay(mCursorOverlay.get()); mTrackPanel->RemoveOverlay(mIndicatorOverlay.get()); } - - wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(AudacityProject::OnCapture), - NULL, - this); } void AudacityProject::ApplyUpdatedTheme() @@ -2715,11 +2710,6 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event) #endif } - this->Disconnect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(ViewInfo::OnTimer), - NULL, - &mViewInfo); - // Destroys this pSelf.reset(); mRuler = nullptr; @@ -6038,14 +6028,6 @@ AudacityProject::PlaybackScroller::PlaybackScroller(AudacityProject *project) this); } -AudacityProject::PlaybackScroller::~PlaybackScroller() -{ - mProject->Disconnect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(PlaybackScroller::OnTimer), - NULL, - this); -} - void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event) { // Let other listeners get the notification diff --git a/src/Project.h b/src/Project.h index f6201e790..4d8faf62f 100644 --- a/src/Project.h +++ b/src/Project.h @@ -793,7 +793,6 @@ public: { public: explicit PlaybackScroller(AudacityProject *project); - ~PlaybackScroller(); enum class Mode { Off, diff --git a/src/Track.cpp b/src/Track.cpp index 894b27f6b..3ea3774cc 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -770,7 +770,7 @@ Track *SyncLockedTracksIterator::Last(bool skiplinked) // // The TrackList sends events whenever certain updates occur to the list it // is managing. Any other classes that may be interested in get these updates -// should use TrackList::Connect() and TrackList::Disconnect(). +// should use TrackList::Connect() or TrackList::Bind(). // DEFINE_EVENT_TYPE(EVT_TRACKLIST_PERMUTED); DEFINE_EVENT_TYPE(EVT_TRACKLIST_RESIZING); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index f93a6f79c..87db5f1c0 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -360,20 +360,6 @@ TrackPanel::~TrackPanel() { mTimer.Stop(); - // Unregister for tracklist updates - mTracks->Disconnect(EVT_TRACKLIST_DELETION, - wxCommandEventHandler(TrackPanel::OnTrackListDeletion), - NULL, - this); - mTracks->Disconnect(EVT_TRACKLIST_RESIZING, - wxCommandEventHandler(TrackPanel::OnTrackListResizing), - NULL, - this); - wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(TrackPanel::OnPlayback), - NULL, - this); - // This can happen if a label is being edited and the user presses // ALT+F4 or Command+Q if (HasCapture()) diff --git a/src/TranslatableStringArray.h b/src/TranslatableStringArray.h index a0c787608..b665302be 100644 --- a/src/TranslatableStringArray.h +++ b/src/TranslatableStringArray.h @@ -43,15 +43,6 @@ public: this); } - ~TranslatableArray() - { - if (wxTheApp) - wxTheApp->Disconnect(EVT_LANGUAGE_CHANGE, - wxCommandEventHandler(TranslatableArray::Invalidate), - NULL, - this); - } - const ArrayType& Get() { if (mContents.empty()) diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 49051e2ce..bc1b2f316 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -307,14 +307,6 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, Center(); } -ContrastDialog::~ContrastDialog() -{ - mForegroundRMSText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); - mBackgroundRMSText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); - mPassFailText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); - mDiffText->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); -} - void ContrastDialog::OnGetURL(wxCommandEvent & WXUNUSED(event)) { // Original help page is back on-line (March 2016), but the manual should be more reliable. diff --git a/src/effects/Contrast.h b/src/effects/Contrast.h index c3d28db3c..23dacdc92 100644 --- a/src/effects/Contrast.h +++ b/src/effects/Contrast.h @@ -32,7 +32,6 @@ public: // constructors and destructors ContrastDialog(wxWindow * parent, wxWindowID id, const wxString & title, const wxPoint & pos); - ~ContrastDialog(); wxButton * m_pButton_UseCurrentF; wxButton * m_pButton_UseCurrentB; diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index f76e246b2..e8f16a1d1 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -3845,16 +3845,6 @@ void EffectUIHost::CleanupRealtime() { if (mSupportsRealtime && mInitialized) { - wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(EffectUIHost::OnPlayback), - NULL, - this); - - wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(EffectUIHost::OnCapture), - NULL, - this); - EffectManager::Get().RealtimeRemoveEffect(mEffect); mInitialized = false; diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index 33ef631be..7e5d6fc14 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -89,37 +89,6 @@ KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid, } } -KeyConfigPrefs::~KeyConfigPrefs() -{ - if (mKey) - { - mKey->Disconnect(wxEVT_KEY_DOWN, - wxKeyEventHandler(KeyConfigPrefs::OnHotkeyKeyDown), - NULL, - this); - mKey->Disconnect(wxEVT_CHAR, - wxKeyEventHandler(KeyConfigPrefs::OnHotkeyChar), - NULL, - this); - mKey->Disconnect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(KeyConfigPrefs::OnHotkeyKillFocus), - NULL, - this); - } - - if (mFilter) - { - mKey->Disconnect(wxEVT_KEY_DOWN, - wxKeyEventHandler(KeyConfigPrefs::OnFilterKeyDown), - NULL, - this); - mKey->Disconnect(wxEVT_CHAR, - wxKeyEventHandler(KeyConfigPrefs::OnFilterChar), - NULL, - this); - } -} - void KeyConfigPrefs::Populate() { ShuttleGui S(this, eIsCreatingFromPrefs); diff --git a/src/prefs/KeyConfigPrefs.h b/src/prefs/KeyConfigPrefs.h index 19f66233e..8f924d83a 100644 --- a/src/prefs/KeyConfigPrefs.h +++ b/src/prefs/KeyConfigPrefs.h @@ -36,7 +36,6 @@ class KeyConfigPrefs final : public PrefsPanel { public: KeyConfigPrefs(wxWindow * parent, wxWindowID winid, const wxString &name); - ~KeyConfigPrefs(); bool Commit() override; void Cancel() override; wxString HelpPageName() override; diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index f280b6ca3..c773b8172 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -458,30 +458,6 @@ ToolManager::~ToolManager() // crashing when running with Jaws on Windows 10 1703. mTopDock->GetConfiguration().Clear(); mBotDock->GetConfiguration().Clear(); - - // Remove handlers from parent - mParent->Disconnect( wxEVT_LEFT_UP, - wxMouseEventHandler( ToolManager::OnMouse ), - NULL, - this ); - mParent->Disconnect( wxEVT_MOTION, - wxMouseEventHandler( ToolManager::OnMouse ), - NULL, - this ); - mParent->Disconnect( wxEVT_MOUSE_CAPTURE_LOST, - wxMouseCaptureLostEventHandler( ToolManager::OnCaptureLost ), - NULL, - this ); - - // Remove our event handlers - mIndicator->Disconnect( wxEVT_CREATE, - wxWindowCreateEventHandler( ToolManager::OnIndicatorCreate ), - NULL, - this ); - mIndicator->Disconnect( wxEVT_PAINT, - wxPaintEventHandler( ToolManager::OnIndicatorPaint ), - NULL, - this ); } // This table describes the default configuration of the toolbars as diff --git a/src/tracks/ui/PlayIndicatorOverlay.cpp b/src/tracks/ui/PlayIndicatorOverlay.cpp index 370f2ab23..25cffca14 100644 --- a/src/tracks/ui/PlayIndicatorOverlay.cpp +++ b/src/tracks/ui/PlayIndicatorOverlay.cpp @@ -117,11 +117,6 @@ PlayIndicatorOverlay::~PlayIndicatorOverlay() if(ruler) ruler->RemoveOverlay(mPartner.get()); } - - mProject->Disconnect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(PlayIndicatorOverlay::OnTimer), - NULL, - this); } void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event) diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index 65165f293..a4e4c52e0 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -212,10 +212,6 @@ Scrubber::~Scrubber() #endif mProject->PopEventHandler(); - if (wxTheApp) - wxTheApp->Disconnect - (wxEVT_ACTIVATE_APP, - wxActivateEventHandler(Scrubber::OnActivateOrDeactivateApp), NULL, this); } namespace { @@ -736,14 +732,6 @@ ScrubbingOverlay::ScrubbingOverlay(AudacityProject *project) this); } -ScrubbingOverlay::~ScrubbingOverlay() -{ - mProject->Disconnect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(ScrubbingOverlay::OnTimer), - NULL, - this); -} - std::pair ScrubbingOverlay::DoGetRectangle(wxSize) { wxRect rect(mLastScrubRect); diff --git a/src/tracks/ui/Scrubbing.h b/src/tracks/ui/Scrubbing.h index f67f0a501..611240ca2 100644 --- a/src/tracks/ui/Scrubbing.h +++ b/src/tracks/ui/Scrubbing.h @@ -209,7 +209,6 @@ class ScrubbingOverlay final : public wxEvtHandler, public Overlay { public: ScrubbingOverlay(AudacityProject *project); - virtual ~ScrubbingOverlay(); private: std::pair DoGetRectangle(wxSize size) override; diff --git a/src/tracks/ui/SelectHandle.cpp b/src/tracks/ui/SelectHandle.cpp index 6c3b8c456..e40ead22a 100644 --- a/src/tracks/ui/SelectHandle.cpp +++ b/src/tracks/ui/SelectHandle.cpp @@ -1048,15 +1048,6 @@ public: this); } - ~TimerHandler() - { - if (mConnectedProject) - mConnectedProject->Disconnect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(SelectHandle::TimerHandler::OnTimer), - NULL, - this); - } - // Receives timer event notifications, to implement auto-scroll void OnTimer(wxCommandEvent &event); diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index 89747653e..f36905ddb 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -340,35 +340,6 @@ void MeterPanel::Clear() mQueue.Clear(); } -MeterPanel::~MeterPanel() -{ - if (mIsInput) - { - // Unregister for AudioIO events - wxTheApp->Disconnect(EVT_AUDIOIO_MONITOR, - wxCommandEventHandler(MeterPanel::OnAudioIOStatus), - NULL, - this); - wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(MeterPanel::OnAudioIOStatus), - NULL, - this); - } - else - { - wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(MeterPanel::OnAudioIOStatus), - NULL, - this); - } - - // Unregister for our preference update event - wxTheApp->Disconnect(EVT_METER_PREFERENCES_CHANGED, - wxCommandEventHandler(MeterPanel::OnMeterPrefsUpdated), - NULL, - this); -} - void MeterPanel::UpdatePrefs() { mDBRange = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE); diff --git a/src/widgets/Meter.h b/src/widgets/Meter.h index 593fae905..037f1ca0e 100644 --- a/src/widgets/Meter.h +++ b/src/widgets/Meter.h @@ -114,8 +114,6 @@ class MeterPanel final : public wxPanelWrapper Style style = HorizontalStereo, float fDecayRate = 60.0f); - ~MeterPanel(); - bool AcceptsFocus() const override { return s_AcceptsFocus; } bool AcceptsFocusFromKeyboard() const override { return true; } diff --git a/src/widgets/PopupMenuTable.cpp b/src/widgets/PopupMenuTable.cpp index 6aefbcd59..0208da508 100644 --- a/src/widgets/PopupMenuTable.cpp +++ b/src/widgets/PopupMenuTable.cpp @@ -13,6 +13,8 @@ Paul Licameli split from TrackPanel.cpp PopupMenuTable::Menu::~Menu() { + // Event connections between the parent window and the singleton table + // object must be broken when this menu is destroyed. Disconnect(); } diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index c07ef628d..e968b39ca 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -2031,11 +2031,6 @@ AdornedRulerPanel::~AdornedRulerPanel() { if(HasCapture()) ReleaseMouse(); - - wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(AdornedRulerPanel::OnCapture), - NULL, - this); } #if 1 diff --git a/src/widgets/wxPanelWrapper.h b/src/widgets/wxPanelWrapper.h index 1e0934a99..03b509cd6 100644 --- a/src/widgets/wxPanelWrapper.h +++ b/src/widgets/wxPanelWrapper.h @@ -27,11 +27,6 @@ public: { this->Bind(wxEVT_CHAR_HOOK, wxTabTraversalWrapperCharHook); } - - ~wxTabTraversalWrapper() - { - this->Unbind(wxEVT_CHAR_HOOK, wxTabTraversalWrapperCharHook); - } }; class AUDACITY_DLL_API wxPanelWrapper : public wxTabTraversalWrapper From 2f3604bdea9a20df61b82bf4dca4502486155e55 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 12 Feb 2018 16:45:54 -0500 Subject: [PATCH 2/4] Rewrite many calls to Connect() with Bind()... ... it's the more modern way, and does better type checking, without the dubious casts of pointers-to-member-functions. --- src/AudacityLogger.cpp | 52 ++++++++++----------------- src/PluginManager.cpp | 5 ++- src/effects/VST/VSTControlOSX.mm | 2 +- src/prefs/KeyConfigPrefs.cpp | 25 ++++++------- src/toolbars/DeviceToolBar.cpp | 40 +++++++++------------ src/toolbars/MixerToolBar.cpp | 20 +++++------ src/toolbars/SelectionBar.cpp | 20 +++++------ src/toolbars/ToolManager.cpp | 25 ++++++------- src/toolbars/TranscriptionToolBar.cpp | 10 +++--- src/tracks/ui/Scrubbing.cpp | 4 +-- src/widgets/PopupMenuTable.cpp | 10 +++--- src/widgets/PopupMenuTable.h | 7 ++-- 12 files changed, 88 insertions(+), 132 deletions(-) diff --git a/src/AudacityLogger.cpp b/src/AudacityLogger.cpp index 0124cdbcc..c0f95f255 100644 --- a/src/AudacityLogger.cpp +++ b/src/AudacityLogger.cpp @@ -166,42 +166,28 @@ void AudacityLogger::Show(bool show) frame->Layout(); // Hook into the frame events - frame->Connect(wxEVT_CLOSE_WINDOW, + frame->Bind(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(AudacityLogger::OnCloseWindow), - NULL, this); - frame->Connect(LoggerID_Save, - wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AudacityLogger::OnSave), - NULL, - this); - frame->Connect(LoggerID_Clear, - wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AudacityLogger::OnClear), - NULL, - this); - frame->Connect(LoggerID_Close, - wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AudacityLogger::OnClose), - NULL, - this); - - frame->Connect(LoggerID_Save, - wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(AudacityLogger::OnSave), - NULL, - this); - frame->Connect(LoggerID_Clear, - wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(AudacityLogger::OnClear), - NULL, - this); - frame->Connect(LoggerID_Close, - wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(AudacityLogger::OnClose), - NULL, - this); + frame->Bind( wxEVT_COMMAND_MENU_SELECTED, + &AudacityLogger::OnSave, + this, LoggerID_Save); + frame->Bind( wxEVT_COMMAND_MENU_SELECTED, + &AudacityLogger::OnClear, + this, LoggerID_Clear); + frame->Bind( wxEVT_COMMAND_MENU_SELECTED, + &AudacityLogger::OnClose, + this, LoggerID_Close); + frame->Bind( wxEVT_COMMAND_BUTTON_CLICKED, + &AudacityLogger::OnSave, + this, LoggerID_Save); + frame->Bind( wxEVT_COMMAND_BUTTON_CLICKED, + &AudacityLogger::OnClear, + this, LoggerID_Clear); + frame->Bind( wxEVT_COMMAND_BUTTON_CLICKED, + &AudacityLogger::OnClose, + this, LoggerID_Close); mFrame = std::move( frame ); diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index d2616de73..ab3a2bf0f 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -556,9 +556,8 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S) S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES ); mEffects = S.Id(ID_List).AddListControlReportMode(); - mEffects->Connect(wxEVT_KEY_DOWN, - wxKeyEventHandler(PluginRegistrationDialog::OnListChar), - NULL, + mEffects->Bind(wxEVT_KEY_DOWN, + &PluginRegistrationDialog::OnListChar, this); #if wxUSE_ACCESSIBILITY mEffects->SetAccessible(mAx = safenew CheckListAx(mEffects)); diff --git a/src/effects/VST/VSTControlOSX.mm b/src/effects/VST/VSTControlOSX.mm index 13f159b64..f4a6d9002 100644 --- a/src/effects/VST/VSTControlOSX.mm +++ b/src/effects/VST/VSTControlOSX.mm @@ -171,7 +171,7 @@ void VSTControl::CreateCarbon() { OSStatus result; - Connect(wxEVT_SIZE, wxSizeEventHandler(VSTControl::OnSize)); + Bind(wxEVT_SIZE, &VSTControl::OnSize, this); VstRect *rect; diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index 7e5d6fc14..90c0a27bd 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -186,13 +186,11 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S) #endif wxTE_PROCESS_ENTER); mFilter->SetName(wxStripMenuCodes(mFilterLabel->GetLabel())); - mFilter->Connect(wxEVT_KEY_DOWN, - wxKeyEventHandler(KeyConfigPrefs::OnFilterKeyDown), - NULL, + mFilter->Bind(wxEVT_KEY_DOWN, + &KeyConfigPrefs::OnFilterKeyDown, this); - mFilter->Connect(wxEVT_CHAR, - wxKeyEventHandler(KeyConfigPrefs::OnFilterChar), - NULL, + mFilter->Bind(wxEVT_CHAR, + &KeyConfigPrefs::OnFilterChar, this); } S.AddWindow(mFilter, wxALIGN_NOT | wxALIGN_LEFT); @@ -228,17 +226,14 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S) wxTE_PROCESS_ENTER); mKey->SetName(_("Short cut")); - mKey->Connect(wxEVT_KEY_DOWN, - wxKeyEventHandler(KeyConfigPrefs::OnHotkeyKeyDown), - NULL, + mKey->Bind(wxEVT_KEY_DOWN, + &KeyConfigPrefs::OnHotkeyKeyDown, this); - mKey->Connect(wxEVT_CHAR, - wxKeyEventHandler(KeyConfigPrefs::OnHotkeyChar), - NULL, + mKey->Bind(wxEVT_CHAR, + &KeyConfigPrefs::OnHotkeyChar, this); - mKey->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(KeyConfigPrefs::OnHotkeyKillFocus), - NULL, + mKey->Bind(wxEVT_KILL_FOCUS, + &KeyConfigPrefs::OnHotkeyKillFocus, this); } S.AddWindow(mKey); diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index 7a9d50604..68c7565ee 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -125,37 +125,29 @@ void DeviceToolBar::Populate() - mHost->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mHost->Bind(wxEVT_SET_FOCUS, + &DeviceToolBar::OnFocus, this); - mHost->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mHost->Bind(wxEVT_KILL_FOCUS, + &DeviceToolBar::OnFocus, this); - mOutput->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mOutput->Bind(wxEVT_SET_FOCUS, + &DeviceToolBar::OnFocus, this); - mOutput->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mOutput->Bind(wxEVT_KILL_FOCUS, + &DeviceToolBar::OnFocus, this); - mInput->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mInput->Bind(wxEVT_SET_FOCUS, + &DeviceToolBar::OnFocus, this); - mInput->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mInput->Bind(wxEVT_KILL_FOCUS, + &DeviceToolBar::OnFocus, this); - mInputChannels->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mInputChannels->Bind(wxEVT_SET_FOCUS, + &DeviceToolBar::OnFocus, this); - mInputChannels->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(DeviceToolBar::OnFocus), - NULL, + mInputChannels->Bind(wxEVT_KILL_FOCUS, + &DeviceToolBar::OnFocus, this); SetNames(); diff --git a/src/toolbars/MixerToolBar.cpp b/src/toolbars/MixerToolBar.cpp index 4b377923e..d4916b28a 100644 --- a/src/toolbars/MixerToolBar.cpp +++ b/src/toolbars/MixerToolBar.cpp @@ -94,21 +94,17 @@ void MixerToolBar::Populate() Add(mOutputSlider, 0, wxALIGN_CENTER); // this bit taken from SelectionBar::Populate() - mInputSlider->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(MixerToolBar::OnFocus), - NULL, + mInputSlider->Bind(wxEVT_SET_FOCUS, + &MixerToolBar::OnFocus, this); - mInputSlider->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(MixerToolBar::OnFocus), - NULL, + mInputSlider->Bind(wxEVT_KILL_FOCUS, + &MixerToolBar::OnFocus, this); - mOutputSlider->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(MixerToolBar::OnFocus), - NULL, + mOutputSlider->Bind(wxEVT_SET_FOCUS, + &MixerToolBar::OnFocus, this); - mOutputSlider->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(MixerToolBar::OnFocus), - NULL, + mOutputSlider->Bind(wxEVT_KILL_FOCUS, + &MixerToolBar::OnFocus, this); // Show or hide the input slider based on whether it works mInputSlider->Enable(gAudioIO->InputMixerWorks()); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 72b5ad5f1..e7310a423 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -323,13 +323,11 @@ void SelectionBar::Populate() } #endif - mRateText->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(SelectionBar::OnFocus), - NULL, + mRateText->Bind(wxEVT_SET_FOCUS, + &SelectionBar::OnFocus, this); - mRateText->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(SelectionBar::OnFocus), - NULL, + mRateText->Bind(wxEVT_KILL_FOCUS, + &SelectionBar::OnFocus, this); #ifdef __WXGTK__ @@ -361,13 +359,11 @@ void SelectionBar::Populate() //mSnapTo->SetForegroundColour( clrText2 ); mSnapTo->SetSelection(mListener ? mListener->AS_GetSnapTo() : SNAP_OFF); - mSnapTo->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(SelectionBar::OnFocus), - NULL, + mSnapTo->Bind(wxEVT_SET_FOCUS, + &SelectionBar::OnFocus, this); - mSnapTo->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(SelectionBar::OnFocus), - NULL, + mSnapTo->Bind(wxEVT_KILL_FOCUS, + &SelectionBar::OnFocus, this); AddVLine( mainSizer ); diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index c773b8172..0c84a82cb 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -382,15 +382,13 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent ) }; // Hook the creation event...only needed on GTK, but doesn't hurt for all - mIndicator->Connect( wxEVT_CREATE, - wxWindowCreateEventHandler( ToolManager::OnIndicatorCreate ), - NULL, + mIndicator->Bind( wxEVT_CREATE, + &ToolManager::OnIndicatorCreate, this ); // Hook the paint event...needed for all - mIndicator->Connect( wxEVT_PAINT, - wxPaintEventHandler( ToolManager::OnIndicatorPaint ), - NULL, + mIndicator->Bind( wxEVT_PAINT, + &ToolManager::OnIndicatorPaint, this ); // It's a little shy @@ -398,17 +396,14 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent ) // Hook the parents mouse events...using the parent helps greatly // under GTK - mParent->Connect( wxEVT_LEFT_UP, - wxMouseEventHandler( ToolManager::OnMouse ), - NULL, + mParent->Bind( wxEVT_LEFT_UP, + &ToolManager::OnMouse, this ); - mParent->Connect( wxEVT_MOTION, - wxMouseEventHandler( ToolManager::OnMouse ), - NULL, + mParent->Bind( wxEVT_MOTION, + &ToolManager::OnMouse, this ); - mParent->Connect( wxEVT_MOUSE_CAPTURE_LOST, - wxMouseCaptureLostEventHandler( ToolManager::OnCaptureLost ), - NULL, + mParent->Bind( wxEVT_MOUSE_CAPTURE_LOST, + &ToolManager::OnCaptureLost, this ); // Create the top and bottom docks diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index 0e9b8a977..cabf46b08 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -200,13 +200,11 @@ void TranscriptionToolBar::Populate() mPlaySpeedSlider->Set(mPlaySpeed / 100.0); mPlaySpeedSlider->SetLabel(_("Playback Speed")); Add( mPlaySpeedSlider, 0, wxALIGN_CENTER ); - mPlaySpeedSlider->Connect(wxEVT_SET_FOCUS, - wxFocusEventHandler(TranscriptionToolBar::OnFocus), - NULL, + mPlaySpeedSlider->Bind(wxEVT_SET_FOCUS, + &TranscriptionToolBar::OnFocus, this); - mPlaySpeedSlider->Connect(wxEVT_KILL_FOCUS, - wxFocusEventHandler(TranscriptionToolBar::OnFocus), - NULL, + mPlaySpeedSlider->Bind(wxEVT_KILL_FOCUS, + &TranscriptionToolBar::OnFocus, this); #ifdef EXPERIMENTAL_VOICE_DETECTION diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index a4e4c52e0..46e148ab6 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -198,9 +198,9 @@ Scrubber::Scrubber(AudacityProject *project) { if (wxTheApp) - wxTheApp->Connect + wxTheApp->Bind (wxEVT_ACTIVATE_APP, - wxActivateEventHandler(Scrubber::OnActivateOrDeactivateApp), NULL, this); + &Scrubber::OnActivateOrDeactivateApp, this); mProject->PushEventHandler(&mForwarder); } diff --git a/src/widgets/PopupMenuTable.cpp b/src/widgets/PopupMenuTable.cpp index 0208da508..55fa8ab3e 100644 --- a/src/widgets/PopupMenuTable.cpp +++ b/src/widgets/PopupMenuTable.cpp @@ -21,9 +21,9 @@ PopupMenuTable::Menu::~Menu() void PopupMenuTable::Menu::Extend(PopupMenuTable *pTable) { auto connect = [&]( const PopupMenuTable::Entry *pEntry ) { - this->pParent->Connect - (pEntry->id, wxEVT_COMMAND_MENU_SELECTED, - pEntry->func, NULL, pTable); + this->pParent->Bind + (wxEVT_COMMAND_MENU_SELECTED, + pEntry->func, pTable, pEntry->id); }; for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin(); @@ -69,8 +69,8 @@ void PopupMenuTable::Menu::DisconnectTable(PopupMenuTable *pTable) for (const PopupMenuTable::Entry *pEntry = &*pTable->Get().begin(); pEntry->IsValid(); ++pEntry) { if ( pEntry->IsItem() ) - pParent->Disconnect( pEntry->id, wxEVT_COMMAND_MENU_SELECTED, - pEntry->func, NULL, pTable ); + pParent->Unbind( wxEVT_COMMAND_MENU_SELECTED, + pEntry->func, pTable, pEntry->id ); else if ( pEntry->IsSubMenu() ) // recur DisconnectTable(pEntry->subTable); diff --git a/src/widgets/PopupMenuTable.h b/src/widgets/PopupMenuTable.h index c52f5d5d1..219c46ca2 100644 --- a/src/widgets/PopupMenuTable.h +++ b/src/widgets/PopupMenuTable.h @@ -36,11 +36,11 @@ struct PopupMenuTableEntry Type type; int id; wxString caption; - wxObjectEventFunction func; + wxCommandEventFunction func; PopupMenuTable *subTable; PopupMenuTableEntry(Type type_, int id_, wxString caption_, - wxObjectEventFunction func_, PopupMenuTable *subTable_) + wxCommandEventFunction func_, PopupMenuTable *subTable_) : type(type_) , id(id_) , caption(caption_) @@ -165,8 +165,7 @@ void HandlerClass::Populate() { \ type, \ id, \ string, \ - (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction) \ - (&My::memFn), \ + (wxCommandEventFunction) (&My::memFn), \ nullptr ) #define POPUP_MENU_ITEM(id, string, memFn) \ From e6e8e3251c277a4f9cc18d9fead6d049b5a1a71c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 12 Feb 2018 17:27:51 -0500 Subject: [PATCH 3/4] Rewrite more Connect() with Bind(), which were type incorrect... ... though harmlessly so. They called to nonstatic member functions of classes with improper this pointers; though the functions did not use this. Bind events to nonmember funtions instead. Sometimes just to empty lambdas to consume the event and ignore it, blocking other handlers. --- src/HistoryWindow.cpp | 18 ++++++++--------- src/HistoryWindow.h | 1 - src/effects/Contrast.cpp | 34 ++++++++++++++++--------------- src/effects/Contrast.h | 1 - src/effects/Equalization.cpp | 9 +++------ src/effects/Equalization.h | 1 - src/effects/VST/VSTEffect.cpp | 38 +++++++++++++++++------------------ src/effects/VST/VSTEffect.h | 1 - src/widgets/Grid.h | 8 +++++--- 9 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 1a8eb328b..fc86a3e8d 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -95,11 +95,15 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): { // FIXME: Textbox labels have inconsistent capitalization mTotal = S.Id(ID_TOTAL).AddTextBox(_("&Total space used"), wxT("0"), 10); - mTotal->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); + mTotal->Bind(wxEVT_KEY_DOWN, + // ignore it + [](wxEvent&){}); S.AddVariableText( {} )->Hide(); mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10); - mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); + mAvail->Bind(wxEVT_KEY_DOWN, + // ignore it + [](wxEvent&){}); S.AddVariableText( {} )->Hide(); S.AddPrompt(_("&Levels To Discard")); @@ -117,7 +121,9 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): mDiscard = S.Id(ID_DISCARD).AddButton(_("&Discard")); mClipboard = S.AddTextBox(_("Clipboard space used"), wxT("0"), 10); - mClipboard->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); + mClipboard->Bind(wxEVT_KEY_DOWN, + // ignore it + [](wxEvent&){}); S.Id(ID_DISCARD_CLIPBOARD).AddButton(_("Discard")); } S.EndMultiColumn(); @@ -294,9 +300,3 @@ void HistoryWindow::OnSize(wxSizeEvent & WXUNUSED(event)) if (mList->GetItemCount() > 0) mList->EnsureVisible(mSelected); } - -void HistoryWindow::OnChar(wxKeyEvent &event) -{ - event.Skip(false); - return; -} diff --git a/src/HistoryWindow.h b/src/HistoryWindow.h index c7cd68d2c..7b4f17a78 100644 --- a/src/HistoryWindow.h +++ b/src/HistoryWindow.h @@ -38,7 +38,6 @@ class HistoryWindow final : public wxDialogWrapper { void OnSize(wxSizeEvent & event); void OnCloseWindow(wxCloseEvent & WXUNUSED(event)); - void OnChar(wxKeyEvent & event); void OnItemSelected(wxListEvent & event); void OnDiscard(wxCommandEvent & event); void OnDiscardClipboard(wxCommandEvent & event); diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index bc1b2f316..4ce14515b 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -152,6 +152,20 @@ BEGIN_EVENT_TABLE(ContrastDialog,wxDialogWrapper) EVT_BUTTON(wxID_CANCEL, ContrastDialog::OnClose) END_EVENT_TABLE() +static void OnChar(wxKeyEvent & event) +{ + // Is this still required? + if (event.GetKeyCode() == WXK_TAB) { + // pass to next handler + event.Skip(); + return; + } + + // ignore any other key + event.Skip(false); + return; +} + /* i18n-hint: WCAG2 is the 'Web Content Accessibility Guidelines (WCAG) 2.0', see http://www.w3.org/TR/WCAG20/ */ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, const wxString & title, @@ -235,7 +249,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, m_pButton_UseCurrentF = S.Id(ID_BUTTON_USECURRENTF).AddButton(_("&Measure selection")); mForegroundRMSText=S.Id(ID_FOREGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17); - mForegroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mForegroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar); //Background S.AddFixedText(_("&Background:")); @@ -267,7 +281,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, m_pButton_UseCurrentB = S.Id(ID_BUTTON_USECURRENTB).AddButton(_("Mea&sure selection")); mBackgroundRMSText = S.Id(ID_BACKGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17); - mBackgroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mBackgroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar); } S.EndMultiColumn(); } @@ -280,11 +294,11 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, { S.AddFixedText(_("Co&ntrast Result:")); mPassFailText = S.Id(ID_RESULTS_TEXT).AddTextBox( {}, wxT(""), 50); - mPassFailText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mPassFailText->Bind(wxEVT_KEY_DOWN, OnChar); m_pButton_Reset = S.Id(ID_BUTTON_RESET).AddButton(_("R&eset")); S.AddFixedText(_("&Difference:")); mDiffText = S.Id(ID_RESULTSDB_TEXT).AddTextBox( {}, wxT(""), 50); - mDiffText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mDiffText->Bind(wxEVT_KEY_DOWN, OnChar); m_pButton_Export = S.Id(ID_BUTTON_EXPORT).AddButton(_("E&xport...")); } S.EndMultiColumn(); @@ -588,15 +602,3 @@ void ContrastDialog::OnReset(wxCommandEvent & /*event*/) mPassFailText->ChangeValue(wxT("")); mDiffText->ChangeValue(wxT("")); } - -void ContrastDialog::OnChar(wxKeyEvent & event) -{ - // Is this still required? - if (event.GetKeyCode() == WXK_TAB) { - event.Skip(); - return; - } - - event.Skip(false); - return; -} diff --git a/src/effects/Contrast.h b/src/effects/Contrast.h index 23dacdc92..023998bdf 100644 --- a/src/effects/Contrast.h +++ b/src/effects/Contrast.h @@ -62,7 +62,6 @@ private: void results(); void OnReset(wxCommandEvent & event); void OnClose(wxCommandEvent & event); - void OnChar(wxKeyEvent &event); wxTextCtrl *mForegroundRMSText; wxTextCtrl *mBackgroundRMSText; diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index b9a5aa655..af78f1966 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -717,7 +717,9 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) mSliders[i] = safenew wxSlider(mGraphicPanel, ID_Slider + i, 0, -20, +20, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE); - mSliders[i]->Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(EffectEqualization::OnErase)); + mSliders[i]->Bind(wxEVT_ERASE_BACKGROUND, + // ignore it + [](wxEvent&){}); #if wxUSE_ACCESSIBILITY wxString name; if( kThirdOct[i] < 1000.) @@ -2592,11 +2594,6 @@ void EffectEqualization::OnSize(wxSizeEvent & event) event.Skip(); } -void EffectEqualization::OnErase(wxEraseEvent & WXUNUSED(event)) -{ - // Ignore it -} - void EffectEqualization::OnSlider(wxCommandEvent & event) { wxSlider *s = (wxSlider *)event.GetEventObject(); diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h index 3b4d4ac05..238e72b72 100644 --- a/src/effects/Equalization.h +++ b/src/effects/Equalization.h @@ -172,7 +172,6 @@ private: double splint(double x[], double y[], size_t n, double y2[], double xr); void OnSize( wxSizeEvent & event ); - void OnErase( wxEraseEvent & event ); void OnSlider( wxCommandEvent & event ); void OnInterp( wxCommandEvent & event ); void OnSliderM( wxCommandEvent & event ); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 101b24832..b6c4d7ad3 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2755,6 +2755,24 @@ void VSTEffect::RemoveHandler() { } +static void OnSize(wxSizeEvent & evt) +{ + evt.Skip(); + + // Once the parent dialog reaches its final size as indicated by + // a non-default minimum size, we set the maximum size to match. + // This is a bit of a hack to prevent VSTs GUI windows from resizing + // there's no real reason to allow it. But, there should be a better + // way of handling it. + wxWindow *w = (wxWindow *) evt.GetEventObject(); + wxSize sz = w->GetMinSize(); + + if (sz != wxDefaultSize) + { + w->SetMaxSize(sz); + } +} + void VSTEffect::BuildFancy() { // Turn the power on...some effects need this when the editor is open @@ -2782,7 +2800,7 @@ void VSTEffect::BuildFancy() NeedEditIdle(true); - mDialog->Connect(wxEVT_SIZE, wxSizeEventHandler(VSTEffect::OnSize)); + mDialog->Bind(wxEVT_SIZE, OnSize); #ifdef __WXMAC__ #ifdef __WX_EVTLOOP_BUSY_WAITING__ @@ -2968,24 +2986,6 @@ void VSTEffect::RefreshParameters(int skip) } } -void VSTEffect::OnSize(wxSizeEvent & evt) -{ - evt.Skip(); - - // Once the parent dialog reaches it's final size as indicated by - // a non-default minimum size, we set the maximum size to match. - // This is a bit of a hack to prevent VSTs GUI windows from resizing - // there's no real reason to allow it. But, there should be a better - // way of handling it. - wxWindow *w = (wxWindow *) evt.GetEventObject(); - wxSize sz = w->GetMinSize(); - - if (sz != wxDefaultSize) - { - w->SetMaxSize(sz); - } -} - void VSTEffect::OnSizeWindow(wxCommandEvent & evt) { if (!mControl) diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 69443c652..33cf391c9 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -195,7 +195,6 @@ private: // UI void OnSlider(wxCommandEvent & evt); - void OnSize(wxSizeEvent & evt); void OnSizeWindow(wxCommandEvent & evt); void OnUpdateDisplay(wxCommandEvent & evt); diff --git a/src/widgets/Grid.h b/src/widgets/Grid.h index 9b44119e1..8992ef48e 100644 --- a/src/widgets/Grid.h +++ b/src/widgets/Grid.h @@ -167,13 +167,15 @@ public: public: void ConnectEvent(wxWindow *w) { - w->GetEventHandler()->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(FocusHandler::OnKillFocus)); + // Need to use a named function pointer, not a lambda, so that we + // can unbind the same later + w->GetEventHandler()->Bind(wxEVT_KILL_FOCUS, OnKillFocus); }; void DisconnectEvent(wxWindow *w) { - w->GetEventHandler()->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(FocusHandler::OnKillFocus)); + w->GetEventHandler()->Unbind(wxEVT_KILL_FOCUS, OnKillFocus); }; - void OnKillFocus(wxFocusEvent & WXUNUSED(event)) + static void OnKillFocus(wxFocusEvent & WXUNUSED(event)) { return; }; From 2fbe04eda0ae0e84d0b326a2044a1bc744e20ac6 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 12 Feb 2018 18:09:20 -0500 Subject: [PATCH 4/4] Replace more Connect with Bind; needed redeclaration of custom events --- src/AudacityApp.cpp | 2 +- src/AudioIO.cpp | 6 +++--- src/AudioIO.h | 9 ++++++--- src/HistoryWindow.cpp | 10 ++++------ src/LyricsWindow.cpp | 5 ++--- src/MixerBoard.cpp | 5 ++--- src/Project.cpp | 15 ++++++--------- src/Track.cpp | 6 +++--- src/Track.h | 9 ++++++--- src/TrackPanel.cpp | 17 +++++++---------- src/TrackPanel.h | 3 ++- src/TranslatableStringArray.h | 7 +++---- src/effects/Effect.cpp | 10 ++++------ src/tracks/ui/PlayIndicatorOverlay.cpp | 5 ++--- src/tracks/ui/Scrubbing.cpp | 5 ++--- src/tracks/ui/SelectHandle.cpp | 5 ++--- src/widgets/Meter.cpp | 22 +++++++++------------- src/widgets/Meter.h | 3 ++- src/widgets/Ruler.cpp | 5 ++--- 19 files changed, 68 insertions(+), 81 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index d8b40e0d3..6382cbca8 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -240,7 +240,7 @@ It handles initialization and termination by subclassing wxApp. //////////////////////////////////////////////////////////// DEFINE_EVENT_TYPE(EVT_OPEN_AUDIO_FILE); -DEFINE_EVENT_TYPE(EVT_LANGUAGE_CHANGE); +wxDEFINE_EVENT(EVT_LANGUAGE_CHANGE, wxCommandEvent); #if 0 #ifdef __WXGTK__ diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 622263fa0..296b44e49 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -480,9 +480,9 @@ using std::min; std::unique_ptr ugAudioIO; AudioIO *gAudioIO{}; -DEFINE_EVENT_TYPE(EVT_AUDIOIO_PLAYBACK); -DEFINE_EVENT_TYPE(EVT_AUDIOIO_CAPTURE); -DEFINE_EVENT_TYPE(EVT_AUDIOIO_MONITOR); +wxDEFINE_EVENT(EVT_AUDIOIO_PLAYBACK, wxCommandEvent); +wxDEFINE_EVENT(EVT_AUDIOIO_CAPTURE, wxCommandEvent); +wxDEFINE_EVENT(EVT_AUDIOIO_MONITOR, wxCommandEvent); // static int AudioIO::mNextStreamToken = 0; diff --git a/src/AudioIO.h b/src/AudioIO.h index a878f5df4..5f7fe7934 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -91,9 +91,12 @@ class AudioIOListener; #define AILA_DEF_NUMBER_ANALYSIS 5 #endif -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_PLAYBACK, -1); -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_CAPTURE, -1); -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_MONITOR, -1); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_AUDIOIO_PLAYBACK, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_AUDIOIO_CAPTURE, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_AUDIOIO_MONITOR, wxCommandEvent); // PRL: // If we always run a portaudio output stream (even just to produce silence) diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index fc86a3e8d..0f0b1d9ce 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -147,14 +147,12 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1)); mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(HistoryWindow::OnAudioIO), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, + &HistoryWindow::OnAudioIO, this); - wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(HistoryWindow::OnAudioIO), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, + &HistoryWindow::OnAudioIO, this); } diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index 527d64c64..8ca42b031 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -126,9 +126,8 @@ LyricsWindow::LyricsWindow(AudacityProject *parent): //} // Events from the project don't propagate directly to this other frame, so... - mProject->Connect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(LyricsWindow::OnTimer), - NULL, + mProject->Bind(EVT_TRACK_PANEL_TIMER, + &LyricsWindow::OnTimer, this); Center(); } diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index ea3a86bc2..fd8c6b3ac 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -928,9 +928,8 @@ MixerBoard::MixerBoard(AudacityProject* pProject, mTracks = mProject->GetTracks(); // Events from the project don't propagate directly to this other frame, so... - mProject->Connect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(MixerBoard::OnTimer), - NULL, + mProject->Bind(EVT_TRACK_PANEL_TIMER, + &MixerBoard::OnTimer, this); } diff --git a/src/Project.cpp b/src/Project.cpp index c77e09862..cf071cd3e 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -1098,9 +1098,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, // because it must // attach its timer event handler later (so that its handler is invoked // earlier) - this->Connect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(ViewInfo::OnTimer), - NULL, + this->Bind(EVT_TRACK_PANEL_TIMER, + &ViewInfo::OnTimer, &mViewInfo); // Add the overlays, in the sequence in which they will be painted @@ -1227,9 +1226,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, mTrackPanel->SetDropTarget(safenew DropTarget(this)); #endif - wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(AudacityProject::OnCapture), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, + &AudacityProject::OnCapture, this); //Initialize the last selection adjustment time. @@ -6022,9 +6020,8 @@ double AudacityProject::GetZoomOfPref( const wxString & PresetPrefName, int defa AudacityProject::PlaybackScroller::PlaybackScroller(AudacityProject *project) : mProject(project) { - mProject->Connect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(PlaybackScroller::OnTimer), - NULL, + mProject->Bind(EVT_TRACK_PANEL_TIMER, + &PlaybackScroller::OnTimer, this); } diff --git a/src/Track.cpp b/src/Track.cpp index 3ea3774cc..7542a10f2 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -772,9 +772,9 @@ Track *SyncLockedTracksIterator::Last(bool skiplinked) // is managing. Any other classes that may be interested in get these updates // should use TrackList::Connect() or TrackList::Bind(). // -DEFINE_EVENT_TYPE(EVT_TRACKLIST_PERMUTED); -DEFINE_EVENT_TYPE(EVT_TRACKLIST_RESIZING); -DEFINE_EVENT_TYPE(EVT_TRACKLIST_DELETION); +wxDEFINE_EVENT(EVT_TRACKLIST_PERMUTED, wxCommandEvent); +wxDEFINE_EVENT(EVT_TRACKLIST_RESIZING, wxCommandEvent); +wxDEFINE_EVENT(EVT_TRACKLIST_DELETION, wxCommandEvent); // same value as in the default constructed TrackId: long TrackList::sCounter = -1; diff --git a/src/Track.h b/src/Track.h index fe456123f..d04257ebc 100644 --- a/src/Track.h +++ b/src/Track.h @@ -596,15 +596,18 @@ struct TrackListEvent : public wxCommandEvent }; // Posted when tracks are reordered but otherwise unchanged. -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_PERMUTED, -1); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_TRACKLIST_PERMUTED, wxCommandEvent); // Posted when some track was added or changed its height. // Cast to TrackListEvent and examine mpTrack to retrieve it. -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_RESIZING, -1); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_TRACKLIST_RESIZING, wxCommandEvent); // Posted when a track has been deleted from a tracklist. // Also posted when one track replaces another -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_DELETION, -1); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_TRACKLIST_DELETION, wxCommandEvent); class TrackList final : public wxEvtHandler, public ListOfTracks { diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 87db5f1c0..3c0d95e1f 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -186,7 +186,7 @@ is time to refresh some aspect of the screen. #include "widgets/Ruler.h" #include -DEFINE_EVENT_TYPE(EVT_TRACK_PANEL_TIMER) +wxDEFINE_EVENT(EVT_TRACK_PANEL_TIMER, wxCommandEvent); /* @@ -341,17 +341,14 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, GetProject()->Bind(wxEVT_IDLE, &TrackPanel::OnIdle, this); // Register for tracklist updates - mTracks->Connect(EVT_TRACKLIST_RESIZING, - wxCommandEventHandler(TrackPanel::OnTrackListResizing), - NULL, + mTracks->Bind(EVT_TRACKLIST_RESIZING, + &TrackPanel::OnTrackListResizing, this); - mTracks->Connect(EVT_TRACKLIST_DELETION, - wxCommandEventHandler(TrackPanel::OnTrackListDeletion), - NULL, + mTracks->Bind(EVT_TRACKLIST_DELETION, + &TrackPanel::OnTrackListDeletion, this); - wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(TrackPanel::OnPlayback), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, + &TrackPanel::OnPlayback, this); } diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 907ab3794..b182fd49c 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -78,7 +78,8 @@ enum class UndoPush : unsigned char; #pragma warning( disable: 4251 ) #endif -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACK_PANEL_TIMER, -1); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_TRACK_PANEL_TIMER, wxCommandEvent); enum { kTimerInterval = 50, // milliseconds diff --git a/src/TranslatableStringArray.h b/src/TranslatableStringArray.h index b665302be..132e3cccc 100644 --- a/src/TranslatableStringArray.h +++ b/src/TranslatableStringArray.h @@ -16,7 +16,7 @@ Paul Licameli class wxArrayString; -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_LANGUAGE_CHANGE, -1); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_LANGUAGE_CHANGE, wxCommandEvent); /* This class can maintain a static table containing user visible strings that updates @@ -37,9 +37,8 @@ public: TranslatableArray() { if (wxTheApp) - wxTheApp->Connect(EVT_LANGUAGE_CHANGE, - wxCommandEventHandler(TranslatableArray::Invalidate), - NULL, + wxTheApp->Bind(EVT_LANGUAGE_CHANGE, + &TranslatableArray::Invalidate, this); } diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index e8f16a1d1..0e43779e8 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -3827,14 +3827,12 @@ void EffectUIHost::InitializeRealtime() { EffectManager::Get().RealtimeAddEffect(mEffect); - wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(EffectUIHost::OnPlayback), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, + &EffectUIHost::OnPlayback, this); - wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(EffectUIHost::OnCapture), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, + &EffectUIHost::OnCapture, this); mInitialized = true; diff --git a/src/tracks/ui/PlayIndicatorOverlay.cpp b/src/tracks/ui/PlayIndicatorOverlay.cpp index 25cffca14..0305a5580 100644 --- a/src/tracks/ui/PlayIndicatorOverlay.cpp +++ b/src/tracks/ui/PlayIndicatorOverlay.cpp @@ -104,9 +104,8 @@ void PlayIndicatorOverlayBase::Draw(OverlayPanel &panel, wxDC &dc) PlayIndicatorOverlay::PlayIndicatorOverlay(AudacityProject *project) : PlayIndicatorOverlayBase(project, true) { - mProject->Connect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(PlayIndicatorOverlay::OnTimer), - NULL, + mProject->Bind(EVT_TRACK_PANEL_TIMER, + &PlayIndicatorOverlay::OnTimer, this); } diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index 46e148ab6..e6249073d 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -726,9 +726,8 @@ ScrubbingOverlay::ScrubbingOverlay(AudacityProject *project) , mLastScrubSpeedText() , mNextScrubSpeedText() { - mProject->Connect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(ScrubbingOverlay::OnTimer), - NULL, + mProject->Bind(EVT_TRACK_PANEL_TIMER, + &ScrubbingOverlay::OnTimer, this); } diff --git a/src/tracks/ui/SelectHandle.cpp b/src/tracks/ui/SelectHandle.cpp index e40ead22a..1275e19c4 100644 --- a/src/tracks/ui/SelectHandle.cpp +++ b/src/tracks/ui/SelectHandle.cpp @@ -1042,9 +1042,8 @@ public: , mConnectedProject{ pProject } { if (mConnectedProject) - mConnectedProject->Connect(EVT_TRACK_PANEL_TIMER, - wxCommandEventHandler(SelectHandle::TimerHandler::OnTimer), - NULL, + mConnectedProject->Bind(EVT_TRACK_PANEL_TIMER, + &SelectHandle::TimerHandler::OnTimer, this); } diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index f36905ddb..1cfcb65c3 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -176,7 +176,7 @@ bool MeterUpdateQueue::Get(MeterUpdateMsg &msg) const static int gap = 2; // Event used to notify all meters of preference changes -DEFINE_EVENT_TYPE(EVT_METER_PREFERENCES_CHANGED); +wxDEFINE_EVENT(EVT_METER_PREFERENCES_CHANGED, wxCommandEvent); const static wxChar *PrefStyles[] = { @@ -270,19 +270,16 @@ MeterPanel::MeterPanel(AudacityProject *project, mDisabledPen = wxPen(theTheme.Colour( clrMeterDisabledPen), 1, wxSOLID); // Register for our preference update event - wxTheApp->Connect(EVT_METER_PREFERENCES_CHANGED, - wxCommandEventHandler(MeterPanel::OnMeterPrefsUpdated), - NULL, + wxTheApp->Bind(EVT_METER_PREFERENCES_CHANGED, + &MeterPanel::OnMeterPrefsUpdated, this); if (mIsInput) { - wxTheApp->Connect(EVT_AUDIOIO_MONITOR, - wxCommandEventHandler(MeterPanel::OnAudioIOStatus), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_MONITOR, + &MeterPanel::OnAudioIOStatus, this); - wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(MeterPanel::OnAudioIOStatus), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, + &MeterPanel::OnAudioIOStatus, this); mPen = wxPen( theTheme.Colour( clrMeterInputPen ), 1, wxSOLID); @@ -294,9 +291,8 @@ MeterPanel::MeterPanel(AudacityProject *project, } else { // Register for AudioIO events - wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, - wxCommandEventHandler(MeterPanel::OnAudioIOStatus), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, + &MeterPanel::OnAudioIOStatus, this); mPen = wxPen( theTheme.Colour( clrMeterOutputPen ), 1, wxSOLID); diff --git a/src/widgets/Meter.h b/src/widgets/Meter.h index 037f1ca0e..6898181d7 100644 --- a/src/widgets/Meter.h +++ b/src/widgets/Meter.h @@ -23,7 +23,8 @@ #include "Ruler.h" // Event used to notify all meters of preference changes -DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_METER_PREFERENCES_CHANGED, -1); +wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, + EVT_METER_PREFERENCES_CHANGED, wxCommandEvent); // Increase this when we add support for multichannel meters // (most of the code is already there) diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index e968b39ca..1a301c236 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -2021,9 +2021,8 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* project, wxToolTip::Enable(true); #endif - wxTheApp->Connect(EVT_AUDIOIO_CAPTURE, - wxCommandEventHandler(AdornedRulerPanel::OnCapture), - NULL, + wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, + &AdornedRulerPanel::OnCapture, this); }