From 26e0aa735cccbb50adeb2b9ec4c45d11bca6ec98 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 27 Oct 2016 11:31:29 +0100 Subject: [PATCH] Fixed a crash on quit when windows are open in the Juce Demo's windows demo --- examples/Demo/Source/Demos/WindowsDemo.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/Demo/Source/Demos/WindowsDemo.cpp b/examples/Demo/Source/Demos/WindowsDemo.cpp index 8f68f1cb51..81b2a448d6 100644 --- a/examples/Demo/Source/Demos/WindowsDemo.cpp +++ b/examples/Demo/Source/Demos/WindowsDemo.cpp @@ -212,6 +212,15 @@ public: ~WindowsDemo() { + if (dialogWindow != nullptr) + { + dialogWindow->exitModalState (0); + + // we are shutting down: can't wait for the message manager + // to eventually delete this + delete dialogWindow; + } + closeAllWindows(); closeWindowsButton.removeListener (this); @@ -239,6 +248,7 @@ private: // null when the component that it points to is deleted. Array< Component::SafePointer > windows; TextButton showWindowsButton, closeWindowsButton; + SafePointer dialogWindow; void showAllWindows() { @@ -282,8 +292,10 @@ private: options.useNativeTitleBar = false; options.resizable = true; - DialogWindow* dw = options.launchAsync(); - dw->centreWithSize (300, 200); + dialogWindow = options.launchAsync(); + + if (dialogWindow != nullptr) + dialogWindow->centreWithSize (300, 200); } void showDocumentWindow (bool native)