Bug using PopupMenu! It's not just me! :D

Okay, this bug is testable in the JuceDemo.

  • load the Juce demo
  • go to the Misc Widgets page
  • delete the text in both of the left-hand text editors
  • type a few characters in the top box
  • select the text, right-click and COPY it.

so far, so good.

now, right click in the bottom box and click PASTE. the text is pasted. still good.

delete the text from both fields again.

now i prove to you the bug:

right click in the top one, then the bottom one, then the top one, then the bottom one again… each time you right click on one, the menu from the last one is dismissed to create the new one. do this as many times as you can be bothered… then click PASTE.

!POW!, the selection you choose is carried out for every single popupmenu that was created, despite them having been dismissed with each right-click. Thus, the ‘PASTE’ is carried for as many menuclicks you made on each component that was clicked on! Conveniently, the result is the same on both components, but if different components had different responses for the popupmenu result integer, they’d do whatever that was.

The ‘dismiss’ is not captured, instead each instantiation of the menu waits until the final menu has gone - then the final option is returned to EVERY SINGLE function that was waiting for a response.

This is very confusing! I don’t know if PopupMenu is to blame or some other lower level feature that I don’t understand… but it’s quite serious!

goldarn it! That’s a tricky little bug. The problem is that it’s building up modal loops recursively and they’re all sharing the same return value when their modal states end.

I’ve got a fix, but it’s a bit messy, so I won’t post it here, but will put it into the next release.