mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-29 08:43:56 +01:00
Changed lifetime management of UIHandle objects, no singletons...
... Rather, construct them during hit tests (also capturing more state sooner rather than at Click time, and adding some accessors for later use) This also fixes bug 1677 by other means and avoids similar problems. A cell may be implemented to re-use a previously hit handle object, not yet clicked, in a later hit test, by remembering a weak pointer, but TrackPanel holds the strong pointers that determine when the object is destroyed. And the objects will surely be destroyed after drag-release, or ESC key. For now they are also destroyed whenever not dragging, and hit-testing is re-invoked; that will be changed later, so that the re-use mentioned above becomes effective, but still they will be destroyed when the pointer moves from one cell to another.
This commit is contained in:
@@ -770,7 +770,7 @@ void TrackPanel::CancelDragging()
|
||||
ProcessUIHandleResult(
|
||||
this, mRuler, pTrack.get(), NULL, refreshResult);
|
||||
mpClickedTrack.reset();
|
||||
mUIHandle = NULL;
|
||||
mUIHandle.reset();
|
||||
Uncapture();
|
||||
}
|
||||
}
|
||||
@@ -1465,7 +1465,7 @@ try
|
||||
(this, mRuler, pClickedTrack.get(), pTrack.get(), refreshResult);
|
||||
if (refreshResult & RefreshCode::Cancelled) {
|
||||
// Drag decided to abort itself
|
||||
mUIHandle = NULL;
|
||||
mUIHandle.reset();
|
||||
mpClickedTrack.reset();
|
||||
Uncapture( &event );
|
||||
}
|
||||
@@ -1484,7 +1484,7 @@ try
|
||||
// Null this pointer out first before calling Release -- because on Windows, we can
|
||||
// come back recursively to this place during handling of the context menu,
|
||||
// because of a capture lost event.
|
||||
mUIHandle = nullptr;
|
||||
mUIHandle.reset();
|
||||
UIHandle::Result refreshResult =
|
||||
uiHandle->Release( tpmEvent, GetProject(), this );
|
||||
ProcessUIHandleResult
|
||||
@@ -1553,7 +1553,7 @@ void TrackPanel::HandleClick( const TrackPanelMouseEvent &tpmEvent )
|
||||
UIHandle::Result refreshResult =
|
||||
mUIHandle->Click( tpmEvent, GetProject() );
|
||||
if (refreshResult & RefreshCode::Cancelled)
|
||||
mUIHandle = NULL;
|
||||
mUIHandle.reset();
|
||||
else
|
||||
mpClickedTrack = pTrack;
|
||||
ProcessUIHandleResult
|
||||
@@ -3113,7 +3113,7 @@ TrackPanelCellIterator::TrackPanelCellIterator(TrackPanel *trackPanel, bool begi
|
||||
mpCell = mpTrack;
|
||||
else
|
||||
mpCell = trackPanel->GetBackgroundCell();
|
||||
}
|
||||
}
|
||||
|
||||
const auto size = mPanel->GetSize();
|
||||
mRect = { 0, 0, size.x, size.y };
|
||||
|
||||
Reference in New Issue
Block a user