24e848f
From ce1dce113c5eda42f49ba3278bb21c61872ca37d Mon Sep 17 00:00:00 2001
24e848f
From: Paul Cornett <paulcor@users.noreply.github.com>
24e848f
Date: Mon, 28 Aug 2017 20:31:47 -0700
24e848f
Subject: [PATCH] Avoid delayed destruction if TLW was never created. See
24e848f
 #17942
24e848f
24e848f
(cherry picked from commit 4a71ba820f085a3d5a7233e9fd0e23ae4e45af58)
24e848f
---
24e848f
 src/common/toplvcmn.cpp | 6 +++---
24e848f
 1 file changed, 3 insertions(+), 3 deletions(-)
24e848f
24e848f
diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp
24e848f
index ef693690c5d..6a722f8be48 100644
24e848f
--- a/src/common/toplvcmn.cpp
24e848f
+++ b/src/common/toplvcmn.cpp
24e848f
@@ -105,10 +105,10 @@ bool wxTopLevelWindowBase::Destroy()
24e848f
     // as we will be deleted anyhow during its destruction and the pointer
24e848f
     // stored in wxPendingDelete would become invalid, so just delete ourselves
24e848f
     // immediately in this case.
24e848f
-    if ( wxWindow* parent = GetParent() )
24e848f
+    wxWindow* parent = GetParent();
24e848f
+    if ( (parent && parent->IsBeingDeleted()) || !GetHandle() )
24e848f
     {
24e848f
-        if ( parent->IsBeingDeleted() )
24e848f
-            return wxNonOwnedWindow::Destroy();
24e848f
+        return wxNonOwnedWindow::Destroy();
24e848f
     }
24e848f
 
24e848f
     // delayed destruction: the frame will be deleted during the next idle