]> git.saurik.com Git - wxWidgets.git/commitdiff
do allow calling Hide() on the window before it is created
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 May 2009 13:16:53 +0000 (13:16 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 May 2009 13:16:53 +0000 (13:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60699 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp

index eac2874bea98cec3f6042654be3a3b87fbc2ecc9..12342872a71c3c9fc2374b81cf7390e21fe77427 100644 (file)
@@ -2824,28 +2824,39 @@ void wxWindowGTK::DoScreenToClient( int *x, int *y ) const
 
 bool wxWindowGTK::Show( bool show )
 {
-    wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
-
-    if (!wxWindowBase::Show(show))
+    if ( !wxWindowBase::Show(show) )
     {
         // nothing to do
         return false;
     }
 
-    if (show && m_showOnIdle)
+    // notice that we may call Hide() before the window is created and this is
+    // actually useful to create it hidden initially -- but we can't call
+    // Show() before it is created
+    if ( !m_widget )
     {
-        // deferred
+        wxASSERT_MSG( !show, "can't show invalid window" );
+        return true;
     }
-    else
+
+    if ( show )
     {
-        if (show)
-            gtk_widget_show(m_widget);
-        else
-            gtk_widget_hide(m_widget);
-        wxShowEvent eventShow(GetId(), show);
-        eventShow.SetEventObject(this);
-        HandleWindowEvent(eventShow);
+        if ( m_showOnIdle )
+        {
+            // defer until later
+            return true;
+        }
+
+        gtk_widget_show(m_widget);
     }
+    else // hide
+    {
+        gtk_widget_hide(m_widget);
+    }
+
+    wxShowEvent eventShow(GetId(), show);
+    eventShow.SetEventObject(this);
+    HandleWindowEvent(eventShow);
 
     return true;
 }