From a09307abba7f837d8bdd8879fe2457efd32e01a8 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 16 Nov 2008 18:03:08 +0000 Subject: [PATCH] check for self assignment in operator= git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/filename.h | 2 +- include/wx/propgrid/advprops.h | 6 ++++-- include/wx/propgrid/property.h | 7 ++++--- include/wx/propgrid/propgridpagestate.h | 12 ++++++++---- include/wx/vector.h | 7 +++++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/wx/filename.h b/include/wx/filename.h index 2cc5c75b8d..2887a3121b 100644 --- a/include/wx/filename.h +++ b/include/wx/filename.h @@ -175,7 +175,7 @@ public: // assorted assignment operators wxFileName& operator=(const wxFileName& filename) - { Assign(filename); return *this; } + { if (this != &filename) Assign(filename); return *this; } wxFileName& operator=(const wxString& filename) { Assign(filename); return *this; } diff --git a/include/wx/propgrid/advprops.h b/include/wx/propgrid/advprops.h index 22ae110b34..bb02c2eaea 100644 --- a/include/wx/propgrid/advprops.h +++ b/include/wx/propgrid/advprops.h @@ -126,7 +126,8 @@ public: #ifndef SWIG void operator=(const wxColourPropertyValue& cpv) { - Init( cpv.m_type, cpv.m_colour ); + if (this != &cpv) + Init( cpv.m_type, cpv.m_colour ); } private: @@ -289,9 +290,10 @@ public: const wxColour& value = *wxWHITE ); virtual ~wxColourProperty(); -protected: virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const; virtual wxColour GetColour( int index ) const; + +protected: virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const; private: diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index be9739e6fc..7c329b7d1c 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -322,7 +322,7 @@ public: data->IncRef(); variant.SetData(data); variant.SetName(it->first); - it++; + ++it; return true; } @@ -992,7 +992,8 @@ public: #ifndef SWIG void operator= (const wxPGChoices& a) { - AssignData(a.m_data); + if (this != &a) + AssignData(a.m_data); } wxPGChoiceEntry& operator[](unsigned int i) @@ -2355,9 +2356,9 @@ public: int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const; -protected: virtual wxString ValueToString( wxVariant& value, int argFlags ) const; +protected: void SetTextColIndex( unsigned int colInd ) { m_capFgColIndex = (wxByte) colInd; } unsigned int GetTextColIndex() const diff --git a/include/wx/propgrid/propgridpagestate.h b/include/wx/propgrid/propgridpagestate.h index 64a2475d2d..f895366389 100644 --- a/include/wx/propgrid/propgridpagestate.h +++ b/include/wx/propgrid/propgridpagestate.h @@ -234,7 +234,8 @@ private: } \ const CLASS& operator=( const CLASS& it ) \ { \ - Assign(it); \ + if (this != &it) \ + Assign(it); \ return *this; \ } \ CLASS& operator++() { Next(); return *this; } \ @@ -359,9 +360,12 @@ public: #ifndef SWIG const wxPGVIterator& operator=( const wxPGVIterator& it ) { - UnRef(); - m_pIt = it.m_pIt; - m_pIt->IncRef(); + if (this != &it) + { + UnRef(); + m_pIt = it.m_pIt; + m_pIt->IncRef(); + } return *this; } #endif diff --git a/include/wx/vector.h b/include/wx/vector.h index 898a0cc399..64b37b9885 100644 --- a/include/wx/vector.h +++ b/include/wx/vector.h @@ -230,8 +230,11 @@ public: wxVector& operator=(const wxVector& vb) { - clear(); - Copy(vb); + if (this != &vb) + { + clear(); + Copy(vb); + } return *this; } -- 2.45.2