diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index 65db7ff941..4d8b31779a 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -67,6 +67,10 @@ void TooltipWindow::updatePosition (const String& tip, Point pos, Rectangle setVisible (true); } +#if JUCE_DEBUG +static Array activeTooltipWindows; +#endif + void TooltipWindow::displayTip (Point screenPos, const String& tip) { jassert (tip.isNotEmpty()); @@ -97,6 +101,15 @@ void TooltipWindow::displayTip (Point screenPos, const String& tip) | ComponentPeer::windowIgnoresMouseClicks); } + #if JUCE_DEBUG + activeTooltipWindows.addIfNotAlreadyThere (this); + + for (auto* w : activeTooltipWindows) + if (w != this && w->tipShowing == tipShowing) + jassertfalse; // Looks like you have more than one TooltipWindow showing the same tip. + // Be careful not to create more than one instance of this class! + #endif + toFront (false); } } @@ -121,6 +134,10 @@ void TooltipWindow::hideTip() tipShowing.clear(); removeFromDesktop(); setVisible (false); + + #if JUCE_DEBUG + activeTooltipWindows.removeAllInstancesOf (this); + #endif } }