From fa48a920b4520fac4feab563cae0f812ea284dbc Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 21 Apr 2012 15:56:24 +1000 Subject: Avoid warning from cppcheck for not checking for self assignment. --- src/LineMarker.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/LineMarker.h') diff --git a/src/LineMarker.h b/src/LineMarker.h index a501ed6a1..5c73a6217 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -36,7 +36,7 @@ public: image = NULL; } LineMarker(const LineMarker &) { - // Defined to avoid pxpm being blindly copied, not as real copy constructor + // Defined to avoid pxpm being blindly copied, not as a complete copy constructor markType = SC_MARK_CIRCLE; fore = ColourDesired(0,0,0); back = ColourDesired(0xff,0xff,0xff); @@ -49,17 +49,19 @@ public: delete pxpm; delete image; } - LineMarker &operator=(const LineMarker &) { - // Defined to avoid pxpm being blindly copied, not as real assignment operator - markType = SC_MARK_CIRCLE; - fore = ColourDesired(0,0,0); - back = ColourDesired(0xff,0xff,0xff); - backSelected = ColourDesired(0xff,0x00,0x00); - alpha = SC_ALPHA_NOALPHA; - delete pxpm; - pxpm = NULL; - delete image; - image = NULL; + LineMarker &operator=(const LineMarker &other) { + // Defined to avoid pxpm being blindly copied, not as a complete assignment operator + if (this != &other) { + markType = SC_MARK_CIRCLE; + fore = ColourDesired(0,0,0); + back = ColourDesired(0xff,0xff,0xff); + backSelected = ColourDesired(0xff,0x00,0x00); + alpha = SC_ALPHA_NOALPHA; + delete pxpm; + pxpm = NULL; + delete image; + image = NULL; + } return *this; } void SetXPM(const char *textForm); -- cgit v1.2.3