check for self-assignment in operator=
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -68,7 +68,8 @@ public:
|
|||||||
|
|
||||||
wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry)
|
wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry)
|
||||||
{
|
{
|
||||||
Set(entry.m_flags, entry.m_keyCode, entry.m_command, entry.m_item);
|
if (&entry != this)
|
||||||
|
Set(entry.m_flags, entry.m_keyCode, entry.m_command, entry.m_item);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,9 +105,12 @@ public:
|
|||||||
|
|
||||||
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src)
|
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src)
|
||||||
{
|
{
|
||||||
if ( m_owned )
|
if (&src != this)
|
||||||
free(m_str);
|
{
|
||||||
CopyFrom(src);
|
if ( m_owned )
|
||||||
|
free(m_str);
|
||||||
|
CopyFrom(src);
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,9 +320,12 @@ public:
|
|||||||
|
|
||||||
wxMemoryBuffer& operator=(const wxMemoryBuffer& src)
|
wxMemoryBuffer& operator=(const wxMemoryBuffer& src)
|
||||||
{
|
{
|
||||||
m_bufdata->DecRef();
|
if (&src != this)
|
||||||
m_bufdata = src.m_bufdata;
|
{
|
||||||
m_bufdata->IncRef();
|
m_bufdata->DecRef();
|
||||||
|
m_bufdata = src.m_bufdata;
|
||||||
|
m_bufdata->IncRef();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,17 +87,20 @@ public:
|
|||||||
|
|
||||||
wxFontData& operator=(const wxFontData& data)
|
wxFontData& operator=(const wxFontData& data)
|
||||||
{
|
{
|
||||||
wxObject::operator=(data);
|
if (&data != this)
|
||||||
m_fontColour = data.m_fontColour;
|
{
|
||||||
m_showHelp = data.m_showHelp;
|
wxObject::operator=(data);
|
||||||
m_allowSymbols = data.m_allowSymbols;
|
m_fontColour = data.m_fontColour;
|
||||||
m_enableEffects = data.m_enableEffects;
|
m_showHelp = data.m_showHelp;
|
||||||
m_initialFont = data.m_initialFont;
|
m_allowSymbols = data.m_allowSymbols;
|
||||||
m_chosenFont = data.m_chosenFont;
|
m_enableEffects = data.m_enableEffects;
|
||||||
m_minSize = data.m_minSize;
|
m_initialFont = data.m_initialFont;
|
||||||
m_maxSize = data.m_maxSize;
|
m_chosenFont = data.m_chosenFont;
|
||||||
m_encoding = data.m_encoding;
|
m_minSize = data.m_minSize;
|
||||||
m_encodingInfo = data.m_encodingInfo;
|
m_maxSize = data.m_maxSize;
|
||||||
|
m_encoding = data.m_encoding;
|
||||||
|
m_encodingInfo = data.m_encodingInfo;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -334,11 +334,6 @@ public: \
|
|||||||
name() { } \
|
name() { } \
|
||||||
~name() { } \
|
~name() { } \
|
||||||
\
|
\
|
||||||
name& operator=(const name& src) \
|
|
||||||
{ base* temp = (base*) this; \
|
|
||||||
(*temp) = ((const base&)src); \
|
|
||||||
return *this; } \
|
|
||||||
\
|
|
||||||
T& operator[](size_t uiIndex) const \
|
T& operator[](size_t uiIndex) const \
|
||||||
{ return (T&)(base::operator[](uiIndex)); } \
|
{ return (T&)(base::operator[](uiIndex)); } \
|
||||||
T& Item(size_t uiIndex) const \
|
T& Item(size_t uiIndex) const \
|
||||||
|
@@ -778,7 +778,7 @@ public:
|
|||||||
|
|
||||||
virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
|
virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
|
||||||
|
|
||||||
wxMouseEvent& operator=(const wxMouseEvent& event) { Assign(event); return *this; }
|
wxMouseEvent& operator=(const wxMouseEvent& event) { if (&event != this) Assign(event); return *this; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxCoord m_x, m_y;
|
wxCoord m_x, m_y;
|
||||||
@@ -940,22 +940,24 @@ public:
|
|||||||
// example)
|
// example)
|
||||||
wxKeyEvent& operator=(const wxKeyEvent& evt)
|
wxKeyEvent& operator=(const wxKeyEvent& evt)
|
||||||
{
|
{
|
||||||
m_x = evt.m_x;
|
if (&evt != this)
|
||||||
m_y = evt.m_y;
|
{
|
||||||
|
m_x = evt.m_x;
|
||||||
|
m_y = evt.m_y;
|
||||||
|
|
||||||
m_keyCode = evt.m_keyCode;
|
m_keyCode = evt.m_keyCode;
|
||||||
|
|
||||||
m_controlDown = evt.m_controlDown;
|
m_controlDown = evt.m_controlDown;
|
||||||
m_shiftDown = evt.m_shiftDown;
|
m_shiftDown = evt.m_shiftDown;
|
||||||
m_altDown = evt.m_altDown;
|
m_altDown = evt.m_altDown;
|
||||||
m_metaDown = evt.m_metaDown;
|
m_metaDown = evt.m_metaDown;
|
||||||
m_scanCode = evt.m_scanCode;
|
m_scanCode = evt.m_scanCode;
|
||||||
m_rawCode = evt.m_rawCode;
|
m_rawCode = evt.m_rawCode;
|
||||||
m_rawFlags = evt.m_rawFlags;
|
m_rawFlags = evt.m_rawFlags;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
m_uniChar = evt.m_uniChar;
|
m_uniChar = evt.m_uniChar;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2284,7 +2286,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// It makes no sense to copy objects of this class
|
// It makes no sense to copy objects of this class
|
||||||
wxEventConnectionRef& operator = (const wxEventConnectionRef& WXUNUSED(other)) { wxASSERT(0); return *this; }
|
wxEventConnectionRef& operator = (const wxEventConnectionRef& WXUNUSED(other)) { wxFAIL; return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,7 +30,14 @@ public:
|
|||||||
wxDataFormat( const wxCStrData& id ) { InitFromString(id); }
|
wxDataFormat( const wxCStrData& id ) { InitFromString(id); }
|
||||||
|
|
||||||
wxDataFormat& operator=(const wxDataFormat& format)
|
wxDataFormat& operator=(const wxDataFormat& format)
|
||||||
{ m_type = format.m_type; m_format = format.m_format; return *this; }
|
{
|
||||||
|
if (&format != this)
|
||||||
|
{
|
||||||
|
m_type = format.m_type;
|
||||||
|
m_format = format.m_format;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
wxDataFormat& operator=(NativeFormat format)
|
wxDataFormat& operator=(NativeFormat format)
|
||||||
{ SetId(format); return *this; }
|
{ SetId(format); return *this; }
|
||||||
|
|
||||||
|
@@ -161,7 +161,7 @@ public: \
|
|||||||
\
|
\
|
||||||
Iterator() : m_node(0), m_ht(0) {} \
|
Iterator() : m_node(0), m_ht(0) {} \
|
||||||
Iterator( Node* node, const Self* ht ) \
|
Iterator( Node* node, const Self* ht ) \
|
||||||
: m_node(node), m_ht((Self*)ht) {} \
|
: m_node(node), m_ht(wx_const_cast(Self*, ht)) {} \
|
||||||
bool operator ==( const Iterator& it ) const \
|
bool operator ==( const Iterator& it ) const \
|
||||||
{ return m_node == it.m_node; } \
|
{ return m_node == it.m_node; } \
|
||||||
bool operator !=( const Iterator& it ) const \
|
bool operator !=( const Iterator& it ) const \
|
||||||
@@ -204,7 +204,7 @@ public: \
|
|||||||
const_iterator() : Iterator() {} \
|
const_iterator() : Iterator() {} \
|
||||||
const_iterator(iterator i) : Iterator(i) {} \
|
const_iterator(iterator i) : Iterator(i) {} \
|
||||||
const_iterator( Node* node, const Self* ht ) \
|
const_iterator( Node* node, const Self* ht ) \
|
||||||
: Iterator( node, (Self*)ht ) {} \
|
: Iterator(node, wx_const_cast(Self*, ht)) {} \
|
||||||
const_iterator& operator++() { PlusPlus();return *this; } \
|
const_iterator& operator++() { PlusPlus();return *this; } \
|
||||||
const_iterator operator++(int) { const_iterator it=*this;PlusPlus();return it; } \
|
const_iterator operator++(int) { const_iterator it=*this;PlusPlus();return it; } \
|
||||||
const_reference operator *() const { return m_node->m_value; } \
|
const_reference operator *() const { return m_node->m_value; } \
|
||||||
@@ -236,12 +236,15 @@ public: \
|
|||||||
\
|
\
|
||||||
const Self& operator=( const Self& ht ) \
|
const Self& operator=( const Self& ht ) \
|
||||||
{ \
|
{ \
|
||||||
clear(); \
|
if (&ht != this) \
|
||||||
m_hasher = ht.m_hasher; \
|
{ \
|
||||||
m_equals = ht.m_equals; \
|
clear(); \
|
||||||
m_getKey = ht.m_getKey; \
|
m_hasher = ht.m_hasher; \
|
||||||
m_items = ht.m_items; \
|
m_equals = ht.m_equals; \
|
||||||
HashCopy( ht ); \
|
m_getKey = ht.m_getKey; \
|
||||||
|
m_items = ht.m_items; \
|
||||||
|
HashCopy( ht ); \
|
||||||
|
} \
|
||||||
return *this; \
|
return *this; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
@@ -407,7 +410,8 @@ public: \
|
|||||||
typedef const KEY_T const_t1; \
|
typedef const KEY_T const_t1; \
|
||||||
typedef const VALUE_T const_t2; \
|
typedef const VALUE_T const_t2; \
|
||||||
\
|
\
|
||||||
CLASSNAME( const const_t1& f, const const_t2& s ):first(t1(f)),second(t2(s)) {} \
|
CLASSNAME(const const_t1& f, const const_t2& s) \
|
||||||
|
: first(wx_const_cast(t1&, f)), second(wx_const_cast(t2&, s)) {} \
|
||||||
\
|
\
|
||||||
t1 first; \
|
t1 first; \
|
||||||
t2 second; \
|
t2 second; \
|
||||||
|
@@ -22,8 +22,8 @@
|
|||||||
like the old class.
|
like the old class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _WX_LISTH__
|
#ifndef _WX_LIST_H_
|
||||||
#define _WX_LISTH__
|
#define _WX_LIST_H_
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// headers
|
// headers
|
||||||
@@ -469,7 +469,7 @@ protected:
|
|||||||
virtual void DeleteData() { }
|
virtual void DeleteData() { }
|
||||||
public:
|
public:
|
||||||
// for wxList::iterator
|
// for wxList::iterator
|
||||||
void** GetDataPtr() const { return &(((wxNodeBase*)this)->m_data); }
|
void** GetDataPtr() const { return &(wx_const_cast(wxNodeBase*, this)->m_data); }
|
||||||
private:
|
private:
|
||||||
// optional key stuff
|
// optional key stuff
|
||||||
wxListKeyValue m_key;
|
wxListKeyValue m_key;
|
||||||
@@ -732,7 +732,7 @@ private:
|
|||||||
: wxListBase(count, (void **)elements) { } \
|
: wxListBase(count, (void **)elements) { } \
|
||||||
\
|
\
|
||||||
name& operator=(const name& list) \
|
name& operator=(const name& list) \
|
||||||
{ Assign(list); return *this; } \
|
{ if (&list != this) Assign(list); return *this; } \
|
||||||
\
|
\
|
||||||
nodetype *GetFirst() const \
|
nodetype *GetFirst() const \
|
||||||
{ return (nodetype *)wxListBase::GetFirst(); } \
|
{ return (nodetype *)wxListBase::GetFirst(); } \
|
||||||
@@ -1178,7 +1178,7 @@ public:
|
|||||||
|
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL
|
||||||
wxList& operator=(const wxList& list)
|
wxList& operator=(const wxList& list)
|
||||||
{ Assign(list); return *this; }
|
{ if (&list != this) Assign(list); return *this; }
|
||||||
|
|
||||||
// compatibility methods
|
// compatibility methods
|
||||||
void Sort(wxSortCompareFunction compfunc) { wxListBase::Sort(compfunc); }
|
void Sort(wxSortCompareFunction compfunc) { wxListBase::Sort(compfunc); }
|
||||||
@@ -1214,7 +1214,14 @@ public:
|
|||||||
// inefficient!)
|
// inefficient!)
|
||||||
wxStringList(const wxStringList& other) : wxStringListBase() { DeleteContents(true); DoCopy(other); }
|
wxStringList(const wxStringList& other) : wxStringListBase() { DeleteContents(true); DoCopy(other); }
|
||||||
wxStringList& operator=(const wxStringList& other)
|
wxStringList& operator=(const wxStringList& other)
|
||||||
{ Clear(); DoCopy(other); return *this; }
|
{
|
||||||
|
if (&other != this)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
DoCopy(other);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
// makes a copy of the string
|
// makes a copy of the string
|
||||||
|
@@ -657,7 +657,14 @@ public:
|
|||||||
iterator(const iterator& i)
|
iterator(const iterator& i)
|
||||||
: m_cur(i.m_cur), m_node(i.str(), &m_cur) {}
|
: m_cur(i.m_cur), m_node(i.str(), &m_cur) {}
|
||||||
iterator& operator=(const iterator& i)
|
iterator& operator=(const iterator& i)
|
||||||
{ m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; }
|
{
|
||||||
|
if (&i != this)
|
||||||
|
{
|
||||||
|
m_cur = i.m_cur;
|
||||||
|
m_node.set(i.str(), &m_cur);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
reference operator*()
|
reference operator*()
|
||||||
{ return wxUniCharRef::CreateForString(m_node, m_cur); }
|
{ return wxUniCharRef::CreateForString(m_node, m_cur); }
|
||||||
@@ -692,7 +699,14 @@ public:
|
|||||||
: m_cur(i.m_cur), m_node(i.str(), &m_cur) {}
|
: m_cur(i.m_cur), m_node(i.str(), &m_cur) {}
|
||||||
|
|
||||||
const_iterator& operator=(const const_iterator& i)
|
const_iterator& operator=(const const_iterator& i)
|
||||||
{ m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; }
|
{
|
||||||
|
if (&i != this)
|
||||||
|
{
|
||||||
|
m_cur = i.m_cur;
|
||||||
|
m_node.set(i.str(), &m_cur);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
const_iterator& operator=(const iterator& i)
|
const_iterator& operator=(const iterator& i)
|
||||||
{ m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; }
|
{ m_cur = i.m_cur; m_node.set(i.str(), &m_cur); return *this; }
|
||||||
|
|
||||||
@@ -1324,7 +1338,7 @@ public:
|
|||||||
// overloaded assignment
|
// overloaded assignment
|
||||||
// from another wxString
|
// from another wxString
|
||||||
wxString& operator=(const wxString& stringSrc)
|
wxString& operator=(const wxString& stringSrc)
|
||||||
{ m_impl = stringSrc.m_impl; return *this; }
|
{ if (&stringSrc != this) m_impl = stringSrc.m_impl; return *this; }
|
||||||
wxString& operator=(const wxCStrData& cstr)
|
wxString& operator=(const wxCStrData& cstr)
|
||||||
{ return *this = cstr.AsString(); }
|
{ return *this = cstr.AsString(); }
|
||||||
// from a character
|
// from a character
|
||||||
|
@@ -96,7 +96,7 @@ public:
|
|||||||
bool operator&&(bool v) const { return (bool)*this && v; }
|
bool operator&&(bool v) const { return (bool)*this && v; }
|
||||||
|
|
||||||
// Assignment operators:
|
// Assignment operators:
|
||||||
wxUniChar& operator=(const wxUniChar& c) { m_value = c.m_value; return *this; }
|
wxUniChar& operator=(const wxUniChar& c) { if (&c != this) m_value = c.m_value; return *this; }
|
||||||
wxUniChar& operator=(const wxUniCharRef& c);
|
wxUniChar& operator=(const wxUniCharRef& c);
|
||||||
wxUniChar& operator=(char c) { m_value = From8bit(c); return *this; }
|
wxUniChar& operator=(char c) { m_value = From8bit(c); return *this; }
|
||||||
wxUniChar& operator=(unsigned char c) { m_value = From8bit((char)c); return *this; }
|
wxUniChar& operator=(unsigned char c) { m_value = From8bit((char)c); return *this; }
|
||||||
@@ -218,7 +218,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxUniCharRef& operator=(const wxUniCharRef& c)
|
wxUniCharRef& operator=(const wxUniCharRef& c)
|
||||||
{ return *this = c.UniChar(); }
|
{ if (&c != this) *this = c.UniChar(); return *this; }
|
||||||
|
|
||||||
wxUniCharRef& operator=(char c) { return *this = wxUniChar(c); }
|
wxUniCharRef& operator=(char c) { return *this = wxUniChar(c); }
|
||||||
wxUniCharRef& operator=(unsigned char c) { return *this = wxUniChar(c); }
|
wxUniCharRef& operator=(unsigned char c) { return *this = wxUniChar(c); }
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_UTILSH__
|
#ifndef _WX_UTILS_H_
|
||||||
#define _WX_UTILSH__
|
#define _WX_UTILS_H_
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// headers
|
// headers
|
||||||
@@ -136,7 +136,7 @@ class WXDLLIMPEXP_BASE wxPlatform
|
|||||||
public:
|
public:
|
||||||
wxPlatform() { Init(); }
|
wxPlatform() { Init(); }
|
||||||
wxPlatform(const wxPlatform& platform) { Copy(platform); }
|
wxPlatform(const wxPlatform& platform) { Copy(platform); }
|
||||||
void operator = (const wxPlatform& platform) { Copy(platform); }
|
void operator = (const wxPlatform& platform) { if (&platform != this) Copy(platform); }
|
||||||
void Copy(const wxPlatform& platform);
|
void Copy(const wxPlatform& platform);
|
||||||
|
|
||||||
// Specify an optional default value
|
// Specify an optional default value
|
||||||
|
@@ -72,7 +72,8 @@ public:
|
|||||||
|
|
||||||
wxWindowIDRef& operator=(const wxWindowIDRef& id)
|
wxWindowIDRef& operator=(const wxWindowIDRef& id)
|
||||||
{
|
{
|
||||||
Assign(id.m_id);
|
if (&id != this)
|
||||||
|
Assign(id.m_id);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user