1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-17 00:57:40 +02:00

TrackButtonHandle keeps weak_ptr to the cell

This commit is contained in:
Paul Licameli 2017-06-27 20:17:44 -04:00
parent b0c6a67c33
commit e2f0a16839
3 changed files with 11 additions and 5 deletions

View File

@ -148,11 +148,15 @@ MenuButtonHandle &MenuButtonHandle::Instance()
UIHandle::Result MenuButtonHandle::CommitChanges
(const wxMouseEvent &, AudacityProject *, wxWindow *pParent)
{
return mpCell->DoContextMenu(mRect, pParent, NULL);
auto pCell = mpCell.lock();
if (!pCell)
return RefreshCode::Cancelled;
return pCell->DoContextMenu(mRect, pParent, NULL);
}
HitTestResult MenuButtonHandle::HitTest
(const wxMouseEvent &event, const wxRect &rect, TrackPanelCell *pCell)
(const wxMouseEvent &event, const wxRect &rect,
const std::shared_ptr<TrackPanelCell> &pCell)
{
wxRect buttonRect;
TrackInfo::GetTitleBarRect(rect, buttonRect);

View File

@ -76,10 +76,11 @@ protected:
public:
static HitTestResult HitTest
(const wxMouseEvent &event, const wxRect &rect, TrackPanelCell *pCell);
(const wxMouseEvent &event, const wxRect &rect,
const std::shared_ptr<TrackPanelCell> &pCell);
private:
TrackPanelCell *mpCell{};
std::weak_ptr<TrackPanelCell> mpCell;
};
#endif

View File

@ -48,7 +48,8 @@ HitTestResult TrackControls::HitTest
if (NULL != (result = CloseButtonHandle::HitTest(event, rect)).handle)
return result;
if (NULL != (result = MenuButtonHandle::HitTest(event, rect, this)).handle)
if (NULL != (result = MenuButtonHandle::HitTest(event, rect,
this->FindTrack()->GetTrackControl())).handle)
return result;
if (NULL != (result = MinimizeButtonHandle::HitTest(event, rect)).handle)