DocumentWindow setVisible(false) bug?

Under certain circumstances, setVisible(false) does not work on a DocumentWindow. Instead of getting invisible, the window gets unresponsive. You can still see it, but none of its buttons work (neither the window close nor the minimise button).

I got this problem on OSX Catalina with a standalone GUI application. But it might also happen with other OSes.

Here is how to reproduce the problem (see also attached example project):

  1. Go into the Projucer and create a new project of type “Gui Application”.
  2. In the created Main.cpp file scroll to the “initialise” function and add another window to it. Set this second window to invisible. Here is the code:
    void initialise (const String& commandLine) override
        mainWindow.reset (new MainWindow (getApplicationName()));
        mainWindow2.reset (new MainWindow ("MainWindow2"));
        mainWindow2->setTopLeftPosition(100, 100);

It is important, that mainWindow2 is created after mainWindow!
Of course, you also have to add a second mainWindow2 declaration around line 105:

    std::unique_ptr<MainWindow> mainWindow;
    std::unique_ptr<MainWindow> mainWindow2;
  1. Run the application. At first everything is as expected: only one window shows up. But now switch to a different application (for example Safari) and then back to your JUCE application. Now suddenly the invisible window shows up. But it is completely unresponsive. You can’t delete it and you can’t minimise it.

Am I doing something wrong? Or is this indeed a JUCE bug?
I am running JUCE 5.4.5 under OSX Catalina. (5.4 KB)

This commit should fix the issue:

Hi Ed,

thanks for the fast fix. Its working now :slight_smile: