From 3cc570448587520419caf27f2ea2414be372eb89 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 20 May 2009 13:16:53 +0000 Subject: [PATCH] do allow calling Hide() on the window before it is created git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60699 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index eac2874..1234287 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -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; } -- 2.7.4