From 0828f257888ffc08b9bf8fa1c67353a9f943c8d0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 22 Sep 2020 14:43:39 +0300 Subject: [PATCH] Fix crash when a notch is empty. --- share/translations/valentina.ts | 16 ++++++++ share/translations/valentina_cs_CZ.ts | 16 ++++++++ share/translations/valentina_de_DE.ts | 16 ++++++++ share/translations/valentina_el_GR.ts | 16 ++++++++ share/translations/valentina_en_CA.ts | 16 ++++++++ share/translations/valentina_en_IN.ts | 16 ++++++++ share/translations/valentina_en_US.ts | 16 ++++++++ share/translations/valentina_es_ES.ts | 16 ++++++++ share/translations/valentina_fi_FI.ts | 16 ++++++++ share/translations/valentina_fr_FR.ts | 16 ++++++++ share/translations/valentina_he_IL.ts | 16 ++++++++ share/translations/valentina_id_ID.ts | 16 ++++++++ share/translations/valentina_it_IT.ts | 16 ++++++++ share/translations/valentina_nl_NL.ts | 16 ++++++++ share/translations/valentina_pl_PL.ts | 16 ++++++++ share/translations/valentina_pt_BR.ts | 16 ++++++++ share/translations/valentina_ro_RO.ts | 16 ++++++++ share/translations/valentina_ru_RU.ts | 16 ++++++++ share/translations/valentina_uk_UA.ts | 16 ++++++++ share/translations/valentina_zh_CN.ts | 16 ++++++++ src/libs/vlayout/vlayoutpiece.cpp | 58 ++++++++++++++++++++++++--- 21 files changed, 372 insertions(+), 6 deletions(-) diff --git a/share/translations/valentina.ts b/share/translations/valentina.ts index 67746482d..dd073057f 100644 --- a/share/translations/valentina.ts +++ b/share/translations/valentina.ts @@ -9780,6 +9780,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_cs_CZ.ts b/share/translations/valentina_cs_CZ.ts index f1a3a8320..240e205b7 100644 --- a/share/translations/valentina_cs_CZ.ts +++ b/share/translations/valentina_cs_CZ.ts @@ -9565,6 +9565,22 @@ Tato volba se projeví po opětovném spuštění. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_de_DE.ts b/share/translations/valentina_de_DE.ts index a0bd6768b..5ad9e1bc3 100644 --- a/share/translations/valentina_de_DE.ts +++ b/share/translations/valentina_de_DE.ts @@ -9562,6 +9562,22 @@ Diese Option wird nach einem Neustart aktiv. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_el_GR.ts b/share/translations/valentina_el_GR.ts index 4502a879a..6646f7ba1 100644 --- a/share/translations/valentina_el_GR.ts +++ b/share/translations/valentina_el_GR.ts @@ -9374,6 +9374,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QmuParser diff --git a/share/translations/valentina_en_CA.ts b/share/translations/valentina_en_CA.ts index 501f92bed..da9694b9e 100644 --- a/share/translations/valentina_en_CA.ts +++ b/share/translations/valentina_en_CA.ts @@ -9556,6 +9556,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_en_IN.ts b/share/translations/valentina_en_IN.ts index df3db29a1..6aa49cf7c 100644 --- a/share/translations/valentina_en_IN.ts +++ b/share/translations/valentina_en_IN.ts @@ -9556,6 +9556,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_en_US.ts b/share/translations/valentina_en_US.ts index f7d9cc85f..5171ab678 100644 --- a/share/translations/valentina_en_US.ts +++ b/share/translations/valentina_en_US.ts @@ -9556,6 +9556,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_es_ES.ts b/share/translations/valentina_es_ES.ts index ba379d1fa..baeeb6e4e 100644 --- a/share/translations/valentina_es_ES.ts +++ b/share/translations/valentina_es_ES.ts @@ -9563,6 +9563,22 @@ Esta opción surtirá efecto después de reiniciar. Error calculating segment for curve '%1'. %2 Error calculando el segmento para la curva '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_fi_FI.ts b/share/translations/valentina_fi_FI.ts index b9658836d..d15ee6e97 100644 --- a/share/translations/valentina_fi_FI.ts +++ b/share/translations/valentina_fi_FI.ts @@ -8526,6 +8526,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QmuParser diff --git a/share/translations/valentina_fr_FR.ts b/share/translations/valentina_fr_FR.ts index 926c0ef98..cbfdbc9fb 100644 --- a/share/translations/valentina_fr_FR.ts +++ b/share/translations/valentina_fr_FR.ts @@ -9541,6 +9541,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_he_IL.ts b/share/translations/valentina_he_IL.ts index 7ef9d5347..49ed6459c 100644 --- a/share/translations/valentina_he_IL.ts +++ b/share/translations/valentina_he_IL.ts @@ -7489,6 +7489,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QmuParser diff --git a/share/translations/valentina_id_ID.ts b/share/translations/valentina_id_ID.ts index 3de0f9dd9..a0f1d6b6b 100644 --- a/share/translations/valentina_id_ID.ts +++ b/share/translations/valentina_id_ID.ts @@ -7827,6 +7827,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QmuParser diff --git a/share/translations/valentina_it_IT.ts b/share/translations/valentina_it_IT.ts index 774440a92..0ec2d3b99 100644 --- a/share/translations/valentina_it_IT.ts +++ b/share/translations/valentina_it_IT.ts @@ -9551,6 +9551,22 @@ Questa opzione sarà effettiva dopo il riavvio del programma. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_nl_NL.ts b/share/translations/valentina_nl_NL.ts index 7867a44bc..49c81e9fa 100644 --- a/share/translations/valentina_nl_NL.ts +++ b/share/translations/valentina_nl_NL.ts @@ -9562,6 +9562,22 @@ Deze optie wordt actief na een herstart.. Error calculating segment for curve '%1'. %2 Fout bij berekenen segment voor boog '%1'. %2  + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_pl_PL.ts b/share/translations/valentina_pl_PL.ts index 056d4ae58..3f9f1fab9 100644 --- a/share/translations/valentina_pl_PL.ts +++ b/share/translations/valentina_pl_PL.ts @@ -8609,6 +8609,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QmuParser diff --git a/share/translations/valentina_pt_BR.ts b/share/translations/valentina_pt_BR.ts index f54053a02..e4254b91b 100644 --- a/share/translations/valentina_pt_BR.ts +++ b/share/translations/valentina_pt_BR.ts @@ -9539,6 +9539,22 @@ Esta opção terá um efeito após o reinício. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_ro_RO.ts b/share/translations/valentina_ro_RO.ts index 7c221406d..6e287bd3e 100644 --- a/share/translations/valentina_ro_RO.ts +++ b/share/translations/valentina_ro_RO.ts @@ -8493,6 +8493,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QmuParser diff --git a/share/translations/valentina_ru_RU.ts b/share/translations/valentina_ru_RU.ts index ba28f2b01..53a877f38 100644 --- a/share/translations/valentina_ru_RU.ts +++ b/share/translations/valentina_ru_RU.ts @@ -9564,6 +9564,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 Ошибка расчёта сегмента для кривой '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_uk_UA.ts b/share/translations/valentina_uk_UA.ts index 19e182638..e4423067e 100644 --- a/share/translations/valentina_uk_UA.ts +++ b/share/translations/valentina_uk_UA.ts @@ -9557,6 +9557,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QSaveFile diff --git a/share/translations/valentina_zh_CN.ts b/share/translations/valentina_zh_CN.ts index 2d96ea41d..2b59f8ed5 100644 --- a/share/translations/valentina_zh_CN.ts +++ b/share/translations/valentina_zh_CN.ts @@ -7613,6 +7613,22 @@ This option will take an affect after restart. Error calculating segment for curve '%1'. %2 + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty. + + + + Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty. + + + + Cannot prepare passmark '%1' for piece '%2'. Passmark is empty. + + QmuParser diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 08917448c..d87e54255 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -264,8 +264,33 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const int nodeIndex = VPiecePath::indexOfNode(path, pData.id); if (nodeIndex != -1) { - layoutPassmark.lines = passmark.BuiltInSAPassmark(piece, pattern); - layoutPassmark.baseLine = ConstFirst (passmark.BuiltInSAPassmarkBaseLine(piece)); + const QVector lines = passmark.BuiltInSAPassmark(piece, pattern); + if (lines.isEmpty()) + { + const QString errorMsg = + QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty.") + .arg(pData.nodeName, piece.GetName()); + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; + return; + } + + layoutPassmark.lines = lines; + + const QVector baseLines = passmark.BuiltInSAPassmarkBaseLine(piece); + if (baseLines.isEmpty()) + { + const QString errorMsg = + QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is " + "empty.") + .arg(pData.nodeName, piece.GetName()); + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; + return; + } + layoutPassmark.baseLine = ConstFirst (baseLines); + + layoutPassmark.type = pData.passmarkLineType; layoutPassmark.isBuiltIn = true; @@ -295,18 +320,39 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const int nodeIndex = VPiecePath::indexOfNode(path, pData.id); if (nodeIndex != -1) { - QVector lines = + QVector baseLines = passmark.SAPassmarkBaseLine(piece, pattern, static_cast(side)); + if (baseLines.isEmpty()) + { + const QString errorMsg = + QObject::tr("Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty.") + .arg(pData.nodeName, piece.GetName()); + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; + return; + } if (side == PassmarkSide::All || side == PassmarkSide::Right) { - layoutPassmark.baseLine = lines.first(); + layoutPassmark.baseLine = baseLines.first(); } else if (side == PassmarkSide::Right) { - layoutPassmark.baseLine = lines.last(); + layoutPassmark.baseLine = baseLines.last(); } - layoutPassmark.lines = passmark.SAPassmark(piece, pattern, side); + + const QVector lines = passmark.SAPassmark(piece, pattern, side); + if (lines.isEmpty()) + { + const QString errorMsg = + QObject::tr("Cannot prepare passmark '%1' for piece '%2'. Passmark is empty.") + .arg(pData.nodeName, piece.GetName()); + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractApplication::patternMessageSignature + errorMsg; + return; + } + + layoutPassmark.lines = lines; layoutPassmark.type = pData.passmarkLineType; layoutPassmark.isBuiltIn = false;