From 932734c89a4b9d86c43623bee462d546d7c065fe Mon Sep 17 00:00:00 2001 From: Paul-Licameli Date: Sun, 12 Aug 2018 14:43:45 -0400 Subject: [PATCH] Windows: don't crash if double-clicking on ruler during playback --- src/widgets/Ruler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index 57af3f9a4..464766518 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -3087,6 +3087,12 @@ auto AdornedRulerPanel::QPHandle::Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) -> Result { + // Keep a shared pointer to self. Otherwise *this might get deleted + // in HandleQPRelease on Windows! Because there is an event-loop yield + // stopping playback, which caused OnCaptureLost to be called, which caused + // clearing of CellularPanel targets! + auto saveMe = mParent->mQPCell->mHolder.lock(); + auto result = CommonRulerHandle::Release(event, pProject, pParent); if (!( result & RefreshCode::Cancelled )) { if (mClicked == Button::Left) {