Skip to content

[release/3.1] Port ToolTip reentrancy fix from 4.8 #5013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -546,40 +546,51 @@ private void RaiseToolTipClosingEvent(bool reset)
}
finally
{
if (isOpen)
// Raising an event calls out to app code, which
// could cause a re-entrant call to this method that
// sets _currentToopTip to null. If that happens,
// there's no need to do the work again.
if (_currentToolTip != null)
{
_currentToolTip.IsOpen = false;

// Setting IsOpen makes call outs to app code. So it is possible that
// the _currentToolTip is deleted as a result of an action there. If that
// were the case we do not need to set off the timer to close the tooltip.
if (_currentToolTip != null)
if (isOpen)
{
// Keep references and owner set for the fade out or slide animation
// Owner is released when animation completes
_forceCloseTimer = new DispatcherTimer(DispatcherPriority.Normal);
_forceCloseTimer.Interval = Popup.AnimationDelayTime;
_forceCloseTimer.Tick += new EventHandler(OnForceClose);
_forceCloseTimer.Tag = _currentToolTip;
_forceCloseTimer.Start();
_currentToolTip.IsOpen = false;

// Setting IsOpen makes call outs to app code. So it is possible that
// the _currentToolTip is nuked as a result of an action there. If that
// were the case we do not need to set off the timer to close the tooltip.
if (_currentToolTip != null)
{
// Keep references and owner set for the fade out or slide animation
// Owner is released when animation completes
_forceCloseTimer = new DispatcherTimer(DispatcherPriority.Normal);
_forceCloseTimer.Interval = Popup.AnimationDelayTime;
_forceCloseTimer.Tick += new EventHandler(OnForceClose);
_forceCloseTimer.Tag = _currentToolTip;
_forceCloseTimer.Start();
}

_quickShow = true;
ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal);
ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetBetweenShowDelay(o));
ToolTipTimer.Tick += new EventHandler(OnBetweenShowDelay);
ToolTipTimer.Start();
}
else
{
// Release owner now
_currentToolTip.ClearValue(OwnerProperty);

_quickShow = true;
ToolTipTimer = new DispatcherTimer(DispatcherPriority.Normal);
ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetBetweenShowDelay(o));
ToolTipTimer.Tick += new EventHandler(OnBetweenShowDelay);
ToolTipTimer.Start();
}
else
{
// Release owner now
_currentToolTip.ClearValue(OwnerProperty);
if (_ownToolTip)
BindingOperations.ClearBinding(_currentToolTip, ToolTip.ContentProperty);
}

if (_ownToolTip)
BindingOperations.ClearBinding(_currentToolTip, ToolTip.ContentProperty);
if (_currentToolTip != null)
{
_currentToolTip.FromKeyboard = false;
_currentToolTip = null;
}
}
_currentToolTip.FromKeyboard = false;
_currentToolTip = null;
}
}
}
Expand Down