From 8ae9987a29566970456c22f33e667ab30f51fe41 Mon Sep 17 00:00:00 2001 From: PB Date: Tue, 22 Sep 2020 18:59:41 +0200 Subject: [PATCH] Improve code examples in wxDataViewModel documentation Fix variable name for the model. Make the code using wxObjectDataPtr have the same flow as the code using a raw pointer. Format the code to be in accordance with the official guidelines. Closes #18924. --- interface/wx/dataview.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index f975b5c286..2abf7e778b 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -73,9 +73,10 @@ associating the model with a control like this: @code - wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY ); + wxDataViewCtrl *musicCtrl = new wxDataViewCtrl(this, wxID_ANY); wxDataViewModel *musicModel = new MyMusicModel; - m_musicCtrl->AssociateModel( musicModel ); + + musicCtrl->AssociateModel(musicModel); musicModel->DecRef(); // avoid memory leak !! // add columns now @@ -84,11 +85,10 @@ A potentially better way to avoid memory leaks is to use wxObjectDataPtr @code - wxObjectDataPtr musicModel; - - wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY ); - musicModel = new MyMusicModel; - m_musicCtrl->AssociateModel( musicModel.get() ); + wxDataViewCtrl *musicCtrl = new wxDataViewCtrl(this, wxID_ANY); + wxObjectDataPtr musicModel(new MyMusicModel); + + musicCtrl->AssociateModel(musicModel.get()); // add columns now @endcode