From: Vadim Zeitlin Date: Fri, 7 May 2010 23:38:21 +0000 (+0000) Subject: Fix bugs related to two phase creation of wxRibbon classes. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fd6e15974ce2488ba7702658b8daf2a679f62984 Fix bugs related to two phase creation of wxRibbon classes. Add missing wxRibbonControl::Create() method. Ensure that member variables are always initialized by the ctor. Check that we're fully initialized in EVT_SIZE handler. Closes #12018. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64243 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/ribbon/control.h b/include/wx/ribbon/control.h index e1066a615c..7edb02d2f2 100644 --- a/include/wx/ribbon/control.h +++ b/include/wx/ribbon/control.h @@ -24,13 +24,24 @@ class wxRibbonArtProvider; class WXDLLIMPEXP_RIBBON wxRibbonControl : public wxControl { public: - wxRibbonControl() { m_art = NULL; } + wxRibbonControl() { Init(); } wxRibbonControl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxControlNameStr); + const wxString& name = wxControlNameStr) + { + Init(); + + Create(parent, id, pos, size, style, validator, name); + } + + bool Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxControlNameStr); virtual void SetArtProvider(wxRibbonArtProvider* art); wxRibbonArtProvider* GetArtProvider() const {return m_art;} @@ -52,6 +63,9 @@ protected: virtual wxSize DoGetNextLargerSize(wxOrientation direction, wxSize relative_to) const; +private: + void Init() { m_art = NULL; } + #ifndef SWIG DECLARE_CLASS(wxRibbonControl) #endif diff --git a/src/ribbon/buttonbar.cpp b/src/ribbon/buttonbar.cpp index 3262c3b257..ce05643b12 100644 --- a/src/ribbon/buttonbar.cpp +++ b/src/ribbon/buttonbar.cpp @@ -178,6 +178,7 @@ public: wxRibbonButtonBar::wxRibbonButtonBar() { m_layouts_valid = false; + CommonInit (0); } wxRibbonButtonBar::wxRibbonButtonBar(wxWindow* parent, diff --git a/src/ribbon/control.cpp b/src/ribbon/control.cpp index beb97ab70a..d80449445e 100644 --- a/src/ribbon/control.cpp +++ b/src/ribbon/control.cpp @@ -28,20 +28,22 @@ IMPLEMENT_CLASS(wxRibbonControl, wxControl) -wxRibbonControl::wxRibbonControl(wxWindow *parent, wxWindowID id, +bool wxRibbonControl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) - : wxControl(parent, id, pos, size, style, validator, name) { - m_art = NULL; + if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) + return false; wxRibbonControl *ribbon_parent = wxDynamicCast(parent, wxRibbonControl); if(ribbon_parent) { m_art = ribbon_parent->GetArtProvider(); } + + return true; } void wxRibbonControl::SetArtProvider(wxRibbonArtProvider* art) diff --git a/src/ribbon/page.cpp b/src/ribbon/page.cpp index fed553be37..3448462420 100644 --- a/src/ribbon/page.cpp +++ b/src/ribbon/page.cpp @@ -415,9 +415,12 @@ void wxRibbonPage::OnSize(wxSizeEvent& evt) { wxSize new_size = evt.GetSize(); - wxMemoryDC temp_dc; - wxRect invalid_rect = m_art->GetPageBackgroundRedrawArea(temp_dc, this, m_old_size, new_size); - Refresh(true, &invalid_rect); + if (m_art) + { + wxMemoryDC temp_dc; + wxRect invalid_rect = m_art->GetPageBackgroundRedrawArea(temp_dc, this, m_old_size, new_size); + Refresh(true, &invalid_rect); + } m_old_size = new_size; diff --git a/src/ribbon/panel.cpp b/src/ribbon/panel.cpp index 481b9a0597..bb6257dfcf 100644 --- a/src/ribbon/panel.cpp +++ b/src/ribbon/panel.cpp @@ -43,7 +43,7 @@ BEGIN_EVENT_TABLE(wxRibbonPanel, wxRibbonControl) EVT_SIZE(wxRibbonPanel::OnSize) END_EVENT_TABLE() -wxRibbonPanel::wxRibbonPanel() +wxRibbonPanel::wxRibbonPanel() : m_expanded_dummy(NULL), m_expanded_panel(NULL) { }