From 4a1d20810c3b0bd48c5f7cea96de75085ec5d7ab Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 5 Oct 2020 16:49:42 +0300 Subject: [PATCH] New warning check. Piece name is not unique. (cherry picked from commit d5fd1380dc9fe4ce0fe2923a273b05590bb40dd4) --- src/app/valentina/mainwindow.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 3c1ac6bab..e3651d4ec 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -156,6 +156,30 @@ QVector SortDetailsForLayout(const QHash *allD return details; } +//--------------------------------------------------------------------------------------------------------------------- +void WarningNotUniquePieceName(const QHash *allDetails) +{ + QHash::const_iterator i = allDetails->constBegin(); + QSet uniqueNames; + + while (i != allDetails->constEnd()) + { + const QString pieceName = i.value().GetName(); + if (not uniqueNames.contains(pieceName)) + { + uniqueNames.insert(pieceName); + } + else + { + const QString errorMsg = QObject::tr("Piece name '%1' is not unique.").arg(pieceName); + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; + } + + ++i; + } +} + } // anonymous namespace //--------------------------------------------------------------------------------------------------------------------- @@ -2780,6 +2804,8 @@ void MainWindow::ActionDetails(bool checked) ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible); m_statusLabel->setText(QString()); + + WarningNotUniquePieceName(pattern->DataPieces()); } else { @@ -2826,6 +2852,7 @@ void MainWindow::ActionLayout(bool checked) } else { + WarningNotUniquePieceName(allDetails); details = SortDetailsForLayout(allDetails); if (details.count() == 0)