From 4d39e63b55c04e81461a7264b2329730374057c9 Mon Sep 17 00:00:00 2001 From: Simon De Backer Date: Sat, 30 May 2020 00:25:31 +0200 Subject: [PATCH] fix deprecated -Wdeprecated-copy Use copy and swap idiom to implement assignment. --- sources/editor/elementscene.h | 3 ++- sources/titleblockcell.cpp | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sources/editor/elementscene.h b/sources/editor/elementscene.h index 86e5ac8f0..f5ccbf863 100644 --- a/sources/editor/elementscene.h +++ b/sources/editor/elementscene.h @@ -177,7 +177,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions) @param nameslist New set of naes for the currently edited element */ inline void ElementScene::setNames(const NamesList &nameslist) { - m_names_list = nameslist; + NamesList copy(nameslist); + std::swap(m_names_list, copy); } /** diff --git a/sources/titleblockcell.cpp b/sources/titleblockcell.cpp index ebce9714f..d3faa7f2a 100644 --- a/sources/titleblockcell.cpp +++ b/sources/titleblockcell.cpp @@ -60,11 +60,13 @@ void TitleBlockCell::setAttribute(const QString &attribute, const QVariant &attr } else if (attribute == "logo") { logo_reference = attr_value.toString(); } else if (attribute == "label") { - label = qvariant_cast(attr_value); + NamesList copy(qvariant_cast(attr_value)); + std::swap(label, copy); } else if (attribute == "displaylabel") { display_label = attr_value.toBool(); } else if (attribute == "value") { - value = qvariant_cast(attr_value); + NamesList copy(qvariant_cast(attr_value)); + std::swap(value, copy); } else if (attribute == "alignment") { alignment = attr_value.toInt(); } else if (attribute == "fontsize") { @@ -143,8 +145,14 @@ void TitleBlockCell::loadContentFromCell(const TitleBlockCell &other_cell) { value_name = other_cell.value_name; cell_type = other_cell.cell_type; logo_reference = other_cell.logo_reference; - value = other_cell.value; - label = other_cell.label; + { + NamesList copy(other_cell.value); + std::swap(value, copy); + } + { + NamesList copy(other_cell.label); + std::swap(label, copy); + } display_label = other_cell.display_label; font_size = other_cell.font_size; alignment = other_cell.alignment; @@ -176,14 +184,16 @@ void TitleBlockCell::loadContentFromXml(const QDomElement &cell_element) { NamesList value_nameslist; value_nameslist.fromXml(cell_element, names_options); if (!value_nameslist.name().isEmpty()) { - value = value_nameslist; + NamesList copy(value_nameslist); + std::swap(value, copy); } names_options["ParentTagName"] = "label"; NamesList label_nameslist; label_nameslist.fromXml(cell_element, names_options); if (!label_nameslist.name().isEmpty()) { - label = label_nameslist; + NamesList copy(label_nameslist); + std::swap(label, copy); } if (cell_element.hasAttribute("displaylabel")) { -- 2.26.2