runModalLoop & mouse


#1

I wrote a kind of Splashscreen with ProgressBar class that runs before the app starts, which works, but at the end it will only exit its runModalLoop() if I move the mouse. This is still JUCE 146, I read in the forum that there were some problems with runModalLoop() and that it could hang until mouse movement occured, but I didn’t find any specifics, … Is there a quick fix for this and what’s the reason for the problem?


#2

Long since fixed… can’t even remember the details, it was something to do with the event loop waiting for a mouse event before checking the quit flag.


#3

Do you maybe know in which file the bug was, so I could check the SVN for changes? I really can’t find the bug on my own… BTW pressing any key does also make exitModalState() exit for good, not only moving the mouse or pressing the mouse button again.


#4

Sorry, it’s lost in the mists of time… Probably messagemanager or the platform-specific messaging code.


#5

It does not happen on Windows, only on OS X so far, if that’s a clue. I’m gonna try to find it but I know already that this is gonna cost me a day…


#6

ok, i fixed it this way:

[code]
JUCE_TRY
{
while (flags.currentlyModalFlag && flags.visibleFlag)
{
// if (! MessageManager::getInstance()->dispatchNextMessage()) // old!
// break;
MessageManager::getInstance()->dispatchNextMessage(true,0); // new!

        // check whether this component was deleted during the last message
        if (! isValidMessageListener())
            break;
    }
}[/code]

I just wanted to ask you if this couldn’t do any negative side effects (crashes?). Basically dispatchNextMessage() now returns immediately instead of sitting there and waiting.


#7

I think it came down to the fact that the message loop was sitting there waiting for an event, and only when one arrived did it get chance to check whether the quit signal had been sent and exit the loop. The fix would have been to send a dummy event when you call quit. It’s probably described here in the forum somewhere if you search.


#8

Exactly, your solution is even better. So what I did now is to add the postMessage() line in Component::exitModalState()

flags.currentlyModalFlag = false; postMessage (new Message (bogusMessage, 0, 0, 0)); // <--- otherwise it hangs on OS X
Seems to do the job… So I can release my stuff now, thanks.


#9