JUCEApplicaton not shutting down properly

Steps to reproduce(from the tip)

  1. Put a break in shutdown in ApplicationStartup in the JUCE Demo
  2. Make sure this is hitting properly by clicking close button on the Juce demo. The breakpoint will be hit
  3. Re-launch under the debugger, click once on the window’s titlebar to give it focus(or to take focus away from the window’s components)
  4. Now use the mouse to go to the mac menu and choose quit, the breakpoint is not hit.

Point # 4 should go through the class AppDelegateRedirector, I think the NSTerminateNow is the problem.

virtual NSApplicationTerminateReply shouldTerminate()
    if (JUCEApplication::getInstance() != 0)

        if (! MessageManager::getInstance()->hasStopMessageBeenSent())
            return NSTerminateCancel;

    return NSTerminateNow;

changing NSTerminateNow to NSTerminateCancel(and letting JUCE handle stopping itself) seems :? to work.

I think simply returning NSTerminateCancel should do it…that way if the systemRequestedQuit() has been over-riden the code will just continue. If it hasn’t then the dispatch loop will quit and the shutdown code will call as normal.

Its a little weird…i guess the proper way would be to return NSTerminateLater, but that may be too much work for something that probably isn’t needed…


yes… I think you’re right. I’m not completely sure why I did it that way. I’ll change to always return NSTerminateCancel and keep an eye out for anything bad happening…