From: Jaakko Salli Date: Mon, 26 Jan 2009 17:28:29 +0000 (+0000) Subject: Added wxPGChoices::Copy(), tweaked related documentation X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e1ef506e13b7c8e96483b7fc0852dcb46688badd Added wxPGChoices::Copy(), tweaked related documentation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58432 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 176db3d61e..fb4dc1cae2 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -737,6 +737,11 @@ private: Helper class for managing choices of wxPropertyGrid properties. Each entry can have label, value, bitmap, text colour, and background colour. + + wxPGChoices uses reference counting, similar to other wxWidgets classes. + This means that assignment operator and copy constructor only copy the + reference and not the actual data. Use Copy() member function to create a + real copy. @remarks If you do not specify value for entry, index is used. @@ -754,7 +759,10 @@ public: Init(); } - /** Copy constructor. */ + /** + Copy constructor, uses reference counting. To create a real copy, + use Copy() member function instead. + */ wxPGChoices( const wxPGChoices& a ) { if ( a.m_data != wxPGChoicesEmptyData ) @@ -853,6 +861,10 @@ public: wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE ); + /** + Assigns choices data, using reference counting. To create a real copy, + use Copy() member function instead. + */ void Assign( const wxPGChoices& a ) { AssignData(a.m_data); @@ -867,6 +879,17 @@ public: m_data->Clear(); } + /** + Returns a real copy of the choices. + */ + wxPGChoices Copy() const + { + wxPGChoices dst; + dst.EnsureData(); + dst.m_data->CopyDataFrom(m_data); + return dst; + } + void EnsureData() { if ( m_data == wxPGChoicesEmptyData ) diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index 372e6d401e..a8f1465f34 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -1425,7 +1425,15 @@ public: @class wxPGChoices Helper class for managing choices of wxPropertyGrid properties. - Each entry can have label, value, bitmap, text colour, and background colour. + Each entry can have label, value, bitmap, text colour, and background + colour. + + wxPGChoices uses reference counting, similar to other wxWidgets classes. + This means that assignment operator and copy constructor only copy the + reference and not the actual data. Use Copy() member function to create a + real copy. + + @remarks If you do not specify value for entry, index is used. @library{wxpropgrid} @category{propgrid} @@ -1440,7 +1448,10 @@ public: */ wxPGChoices(); - /** Copy constructor. */ + /** + Copy constructor, uses reference counting. To create a real copy, + use Copy() member function instead. + */ wxPGChoices( const wxPGChoices& a ); /** Constructor. */ @@ -1481,7 +1492,8 @@ public: wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE ); /** - Assigns data from another set of choices. + Assigns choices data, using reference counting. To create a real copy, + use Copy() member function instead. */ void Assign( const wxPGChoices& a ); @@ -1495,6 +1507,11 @@ public: */ void Clear(); + /** + Returns a real copy of the choices. + */ + wxPGChoices Copy() const; + /** Returns labe of item. */