Commit ec2b036e authored by Albert Astals Cid's avatar Albert Astals Cid

Return early in operator= if we're assigning to ourselves

Makes bugprone-unhandled-self-assignment happy
parent 98dbe4be
/*
* Copyright (C) 2010-2011, Pino Toscano <pino@kde.org>
* Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
* Copyright (C) 2017, 2018, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2017-2019, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2017, Jeroen Ooms <jeroenooms@gmail.com>
* Copyright (C) 2018, Zsombor Hollay-Horvath <hollay.horvath@gmail.com>
* Copyright (C) 2018, Adam Reichold <adam.reichold@t-online.de>
......@@ -498,6 +498,9 @@ std::vector<std::string> image::supported_image_formats()
*/
image& image::operator=(const image &pt)
{
if (this == &pt)
return *this;
if (pt.d) {
++pt.d->ref;
}
......
......@@ -44,6 +44,9 @@ OutlineItem::OutlineItem(const OutlineItem &other) : m_data{new OutlineItemData{
OutlineItem &OutlineItem::operator=(const OutlineItem &other)
{
if (this == &other)
return *this;
auto *data = new OutlineItemData{*other.m_data};
qSwap(m_data, data);
delete data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment