@@ -546,40 +546,51 @@ private void RaiseToolTipClosingEvent(bool reset)
546
546
}
547
547
finally
548
548
{
549
- if ( isOpen )
549
+ // Raising an event calls out to app code, which
550
+ // could cause a re-entrant call to this method that
551
+ // sets _currentToopTip to null. If that happens,
552
+ // there's no need to do the work again.
553
+ if ( _currentToolTip != null )
550
554
{
551
- _currentToolTip . IsOpen = false ;
552
-
553
- // Setting IsOpen makes call outs to app code. So it is possible that
554
- // the _currentToolTip is deleted as a result of an action there. If that
555
- // were the case we do not need to set off the timer to close the tooltip.
556
- if ( _currentToolTip != null )
555
+ if ( isOpen )
557
556
{
558
- // Keep references and owner set for the fade out or slide animation
559
- // Owner is released when animation completes
560
- _forceCloseTimer = new DispatcherTimer ( DispatcherPriority . Normal ) ;
561
- _forceCloseTimer . Interval = Popup . AnimationDelayTime ;
562
- _forceCloseTimer . Tick += new EventHandler ( OnForceClose ) ;
563
- _forceCloseTimer . Tag = _currentToolTip ;
564
- _forceCloseTimer . Start ( ) ;
557
+ _currentToolTip . IsOpen = false ;
558
+
559
+ // Setting IsOpen makes call outs to app code. So it is possible that
560
+ // the _currentToolTip is nuked as a result of an action there. If that
561
+ // were the case we do not need to set off the timer to close the tooltip.
562
+ if ( _currentToolTip != null )
563
+ {
564
+ // Keep references and owner set for the fade out or slide animation
565
+ // Owner is released when animation completes
566
+ _forceCloseTimer = new DispatcherTimer ( DispatcherPriority . Normal ) ;
567
+ _forceCloseTimer . Interval = Popup . AnimationDelayTime ;
568
+ _forceCloseTimer . Tick += new EventHandler ( OnForceClose ) ;
569
+ _forceCloseTimer . Tag = _currentToolTip ;
570
+ _forceCloseTimer . Start ( ) ;
571
+ }
572
+
573
+ _quickShow = true ;
574
+ ToolTipTimer = new DispatcherTimer ( DispatcherPriority . Normal ) ;
575
+ ToolTipTimer . Interval = TimeSpan . FromMilliseconds ( ToolTipService . GetBetweenShowDelay ( o ) ) ;
576
+ ToolTipTimer . Tick += new EventHandler ( OnBetweenShowDelay ) ;
577
+ ToolTipTimer . Start ( ) ;
565
578
}
579
+ else
580
+ {
581
+ // Release owner now
582
+ _currentToolTip . ClearValue ( OwnerProperty ) ;
566
583
567
- _quickShow = true ;
568
- ToolTipTimer = new DispatcherTimer ( DispatcherPriority . Normal ) ;
569
- ToolTipTimer . Interval = TimeSpan . FromMilliseconds ( ToolTipService . GetBetweenShowDelay ( o ) ) ;
570
- ToolTipTimer . Tick += new EventHandler ( OnBetweenShowDelay ) ;
571
- ToolTipTimer . Start ( ) ;
572
- }
573
- else
574
- {
575
- // Release owner now
576
- _currentToolTip . ClearValue ( OwnerProperty ) ;
584
+ if ( _ownToolTip )
585
+ BindingOperations . ClearBinding ( _currentToolTip , ToolTip . ContentProperty ) ;
586
+ }
577
587
578
- if ( _ownToolTip )
579
- BindingOperations . ClearBinding ( _currentToolTip , ToolTip . ContentProperty ) ;
588
+ if ( _currentToolTip != null )
589
+ {
590
+ _currentToolTip . FromKeyboard = false ;
591
+ _currentToolTip = null ;
592
+ }
580
593
}
581
- _currentToolTip . FromKeyboard = false ;
582
- _currentToolTip = null ;
583
594
}
584
595
}
585
596
}
0 commit comments