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)