From 83666e99093aa0b65c497f7e6c75d98a875667cc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 12 Nov 2008 14:34:40 +0000 Subject: [PATCH] added check for self-assignment to wxPrintData::operator=() (thanks HP aCC for a genuinely useful warning) and also changed it return type to the standard one instead of void git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56744 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cmndata.h | 2 +- src/common/cmndata.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/wx/cmndata.h b/include/wx/cmndata.h index 1ec6859ecb..31269412d8 100644 --- a/include/wx/cmndata.h +++ b/include/wx/cmndata.h @@ -228,7 +228,7 @@ public: wxString GetFilename() const { return m_filename; } void SetFilename( const wxString &filename ) { m_filename = filename; } - void operator=(const wxPrintData& data); + wxPrintData& operator=(const wxPrintData& data); char* GetPrivData() const { return m_privData; } int GetPrivDataLen() const { return m_privDataLen; } diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 8c1309a9df..4a02c49298 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -256,8 +256,11 @@ void wxPrintData::ConvertFromNative() m_nativeData->TransferTo( *this ) ; } -void wxPrintData::operator=(const wxPrintData& data) +wxPrintData& wxPrintData::operator=(const wxPrintData& data) { + if ( &data == this ) + return *this; + m_printNoCopies = data.m_printNoCopies; m_printCollate = data.m_printCollate; m_printOrientation = data.m_printOrientation; @@ -295,6 +298,8 @@ void wxPrintData::operator=(const wxPrintData& data) m_privData = new char[m_privDataLen]; memcpy( m_privData, data.GetPrivData(), m_privDataLen ); } + + return *this; } // Is this data OK for showing the print dialog? -- 2.47.2