From ab7e49deb84e9ff30d36f525fd8485619b87ca0e Mon Sep 17 00:00:00 2001 From: Mariano Reingart Date: Mon, 29 Sep 2014 03:12:59 +0000 Subject: [PATCH] Allow SetFont to be called before Create in wxQT, thanks @seandepagnier git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/qt/window.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 74a3c91fa6..d3a37b92d7 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -274,6 +274,7 @@ void wxWindowQt::PostCreation(bool generic) SetBackgroundColour(wxColour(GetHandle()->palette().background().color())); SetForegroundColour(wxColour(GetHandle()->palette().foreground().color())); + GetHandle()->setFont( wxWindowBase::GetFont().GetHandle() ); } void wxWindowQt::AddChild( wxWindowBase *child ) @@ -422,9 +423,16 @@ void wxWindowQt::Refresh( bool WXUNUSED( eraseBackground ), const wxRect *rect ) bool wxWindowQt::SetFont( const wxFont &font ) { - GetHandle()->setFont( font.GetHandle() ); - - return ( true ); + // SetFont may be called before Create, so the font is stored + // by the base class, and set in PostCreation + + if (GetHandle()) + { + GetHandle()->setFont( font.GetHandle() ); + return true; + } + + return wxWindowBase::SetFont(font); }