Correct wxObjectDataPtr<> assignment from *T to not increase the ref count

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51076 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2008-01-07 15:12:46 +00:00
parent a27555e453
commit e39d30c05b
3 changed files with 21 additions and 6 deletions

View File

@@ -146,8 +146,9 @@ counted object to which this class points.
\constfunc{T*}{operator->}{\void}
Gets a pointer to the reference counted object to which
this class points. Same as \helpref{get}{wxobjectdataptrget}.
Returns a pointer to the reference counted object to which
this class points. If this the internal pointer is NULL,
this method will assert in debug mode.
\membersection{wxObjectDataPtr<T>::operator=}\label{wxobjectdataptroperatorassign}

View File

@@ -456,7 +456,12 @@ public:
}
T *get() const { return m_ptr; }
T *operator->() const { return get(); }
T *operator->() const
{
wxASSERT(m_ptr != NULL);
return get();
}
void reset(T *ptr)
{
@@ -480,8 +485,6 @@ public:
if (m_ptr)
m_ptr->DecRef();
m_ptr = ptr;
if (m_ptr)
m_ptr->IncRef();
return *this;
}

View File

@@ -169,6 +169,11 @@ public:
m_classicalMusicIsKnownToControl = false;
}
~MyMusicModel()
{
delete m_root;
}
// helper method for wxLog
wxString GetTitle( const wxDataViewItem &item )
@@ -575,6 +580,7 @@ class MyFrame : public wxFrame
{
public:
MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int h);
~MyFrame();
public:
void OnQuit(wxCommandEvent& event);
@@ -842,6 +848,11 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
SetSizer( main_sizer );
}
MyFrame::~MyFrame()
{
delete wxLog::SetActiveTarget(m_logOld);
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
Close(true);