From 34ecc6efc4e0653cbbf3a9d3590b2fe2b8732637 Mon Sep 17 00:00:00 2001 From: Graham Dawes Date: Mon, 7 Jan 2019 11:26:17 +0000 Subject: [PATCH] Generate wxWindowCreateEvent when creating windows in wxQt Send the expected event at the very end of window creation process. Closes https://github.com/wxWidgets/wxWidgets/pull/1119 --- src/qt/control.cpp | 7 +++++-- src/qt/dialog.cpp | 7 +++++-- src/qt/frame.cpp | 6 ++++-- src/qt/window.cpp | 3 +++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/qt/control.cpp b/src/qt/control.cpp index eacb2409a1..057619ab7a 100644 --- a/src/qt/control.cpp +++ b/src/qt/control.cpp @@ -58,9 +58,12 @@ bool wxControl::QtCreateControl( wxWindow *parent, wxWindowID id, // Let Qt handle the background: SetBackgroundStyle(wxBG_STYLE_SYSTEM); - PostCreation(false); - return CreateControl( parent, id, pos, size, style, validator, name ); + if (!CreateControl( parent, id, pos, size, style, validator, name )) + return false; + + PostCreation(false); + return true; } wxSize wxControl::DoGetBestSize() const diff --git a/src/qt/dialog.cpp b/src/qt/dialog.cpp index 6c99788e2e..9bb788c27b 100644 --- a/src/qt/dialog.cpp +++ b/src/qt/dialog.cpp @@ -59,10 +59,13 @@ bool wxDialog::Create( wxWindow *parent, wxWindowID id, style |= wxTAB_TRAVERSAL; m_qtWindow = new wxQtDialog( parent, this ); - + + if ( !wxTopLevelWindow::Create( parent, id, title, pos, size, style, name ) ) + return false; + PostCreation(); - return wxTopLevelWindow::Create( parent, id, title, pos, size, style, name ); + return true; } int wxDialog::ShowModal() diff --git a/src/qt/frame.cpp b/src/qt/frame.cpp index f4636dc902..42143793cf 100644 --- a/src/qt/frame.cpp +++ b/src/qt/frame.cpp @@ -70,9 +70,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString& title, GetQMainWindow()->setCentralWidget( new wxQtCentralWidget( parent, this ) ); - PostCreation(); + if ( !wxFrameBase::Create( parent, id, title, pos, size, style, name ) ) + return false; - return wxFrameBase::Create( parent, id, title, pos, size, style, name ); + PostCreation(); + return true; } void wxFrame::SetMenuBar( wxMenuBar *menuBar ) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index f112f3a545..5aa1241f7f 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -287,6 +287,9 @@ void wxWindowQt::PostCreation(bool generic) SetForegroundColour(wxColour(GetHandle()->palette().foreground().color())); GetHandle()->setFont( wxWindowBase::GetFont().GetHandle() ); + + wxWindowCreateEvent event(this); + HandleWindowEvent(event); } void wxWindowQt::AddChild( wxWindowBase *child )