Bug1931: more precautions, higher level and more general...

... Do for release as was already done for click and drag:  hold a shared
pointer.

This will protect against reentrancy surprises as in this bug, where a
reference to the handle may be removed during one of the handle's own
methods.
This commit is contained in:
Paul Licameli 2018-08-12 15:55:27 -04:00
parent 328aa58966
commit 542adefac1
1 changed files with 4 additions and 2 deletions

View File

@ -729,13 +729,15 @@ try
}
else if (event.ButtonUp()) {
// UIHANDLE RELEASE
// copy shared_ptr for safety, as in HandleClick
auto handle = state.mUIHandle;
unsigned moreFlags = state.mMouseOverUpdateFlags;
UIHandle::Result refreshResult =
state.mUIHandle->Release( tpmEvent, GetProject(), this );
handle->Release( tpmEvent, GetProject(), this );
ProcessUIHandleResult
(pClickedCell.get(), pCell.get(),
refreshResult | moreFlags);
state.mUIHandle.reset(), ClearTargets();
state.mUIHandle.reset(), handle.reset(), ClearTargets();
state.mpClickedCell.reset();
// will also Uncapture() below
}