Hi,
I’d like to add a popup when right clicking on a component but I am having a hard time. When I display a popup which has submenus, move over an item that opens a submenu to trigger the opening (without going into the submenu) and then click away from the popup, PopupMenu::Window::inputAttemptWhenModal() tries to call isOverAnyMenu() at a point where the window has already been freed which results in a crash.
A breakpoint in PopupMenu::Window::~Window() gives me the following call stack. The crash happends in inputAttemptWhenModal as soon as timerCallback has returned.
vst.dll!juce::PopupMenu::Window::~Window() Line 306 C++
vst.dll!juce::PopupMenu::Window::`scalar deleting destructor'() + 0x14 bytes C++
vst.dll!juce::ScopedPointer<juce::PopupMenu::Window>::operator=(juce::PopupMenu::Window * const newObjectToTakePossessionOf=0x00000000) Line 124 + 0x20 bytes C++
vst.dll!juce::PopupMenu::Window::hide(const juce::PopupMenu::Item * const item=0x00000000) Line 437 C++
vst.dll!juce::PopupMenu::Window::dismissMenu(const juce::PopupMenu::Item * const item=0x00000000) Line 470 C++
vst.dll!juce::PopupMenu::Window::dismissMenu(const juce::PopupMenu::Item * const item=0x00000000) Line 457 C++
vst.dll!juce::PopupMenu::Window::timerCallback() Line 709 C++
vst.dll!juce::PopupMenu::Window::inputAttemptWhenModal() Line 564 C++
vst.dll!juce::Component::internalModalInputAttempt() Line 2049 C++
vst.dll!juce::Component::internalMouseDown(juce::MouseInputSource & source={...}, const juce::Point<int> & relativePos={...}, const juce::Time & time={...}) Line 2346 C++
vst.dll!juce::MouseInputSourceInternal::sendMouseDown(juce::Component * const comp=0x12070140, const juce::Point<int> & screenPos={...}, const __int64 time=1275511250048) Line 122 + 0x4b bytes C++
I haven’t had the time to dig into the inner workings of the popups, but I really can’t see what I could be doing wrong here since what I am doing is really basic:
virtual void mouseDown (const MouseEvent& e)
{
if (e.mods.isRightButtonDown())
{
PopupMenu& popup = getMyPopup();
const int result = popup.showAt(this);
}
}
Using coordinates or a component to center the popup does not seem to make a difference. I have a TooltipWindow around but it does not seem to make a difference either. I am also using EditorRequiresKeyboardFocus.
Any ideas? I am really stuck on this quite distrubing issue!
Thanks!