From d2bb3203067343b51bf3c543b331741f6fa4ad21 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 7 Apr 2019 12:20:58 +1000 Subject: Make XPM, RGBAImage, and LineMarker copyable and noexcept moveable. This simplifies and optimizes their use in other classes and containers. --- src/LineMarker.cxx | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'src/LineMarker.cxx') diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index 92dd775ca..1c03f0baf 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -26,41 +26,41 @@ using namespace Scintilla; -LineMarker::~LineMarker() { -} - -LineMarker::LineMarker() { - markType = SC_MARK_CIRCLE; - fore = ColourDesired(0, 0, 0); - back = ColourDesired(0xff, 0xff, 0xff); - backSelected = ColourDesired(0xff, 0x00, 0x00); - alpha = SC_ALPHA_NOALPHA; - customDraw = nullptr; -} - -LineMarker::LineMarker(const LineMarker &) { +LineMarker::LineMarker(const LineMarker &other) { // Defined to avoid pxpm and image being blindly copied, not as a complete copy constructor. - markType = SC_MARK_CIRCLE; - fore = ColourDesired(0, 0, 0); - back = ColourDesired(0xff, 0xff, 0xff); - backSelected = ColourDesired(0xff, 0x00, 0x00); - alpha = SC_ALPHA_NOALPHA; - pxpm.reset(); - image.reset(); - customDraw = nullptr; + markType = other.markType; + fore = other.fore; + back = other.back; + backSelected = other.backSelected; + alpha = other.alpha; + if (other.pxpm) + pxpm = std::make_unique(*other.pxpm); + else + pxpm = nullptr; + if (other.image) + image = std::make_unique(*other.image); + else + image = nullptr; + customDraw = other.customDraw; } LineMarker &LineMarker::operator=(const LineMarker &other) { // Defined to avoid pxpm and image 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; - pxpm.reset(); - image.reset(); - customDraw = nullptr; + markType = other.markType; + fore = other.fore; + back = other.back; + backSelected = other.backSelected; + alpha = other.alpha; + if (other.pxpm) + pxpm = std::make_unique(*other.pxpm); + else + pxpm = nullptr; + if (other.image) + image = std::make_unique(*other.image); + else + image = nullptr; + customDraw = other.customDraw; } return *this; } -- cgit v1.2.3