diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 1930ba216..cbf4d159c 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -179,7 +179,7 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t } else { - QString previousItemName = ui.listWidget->item(ui.listWidget->count()-1)->text(); + const QString previousItemName = ui.listWidget->item(ui.listWidget->count()-1)->text(); if(QString::compare(previousItemName, name) != 0) { canAddNewPoint = true; @@ -416,7 +416,7 @@ void DialogDetail::DeleteItem() } //--------------------------------------------------------------------------------------------------------------------- -bool DialogDetail::DetailIsValid() +bool DialogDetail::DetailIsValid() const { if (ui.listWidget->count() < 3) { @@ -430,10 +430,10 @@ bool DialogDetail::DetailIsValid() } else { - for (int i=0; icount()-1; i++) + for (int i=0, sz = ui.listWidget->count()-1; iitem(i)->text(); - QString nextRow = ui.listWidget->item(i+1)->text(); + const QString previousRow = ui.listWidget->item(i)->text(); + const QString nextRow = ui.listWidget->item(i+1)->text(); if (QString::compare(previousRow, nextRow) == 0) { @@ -446,17 +446,21 @@ bool DialogDetail::DetailIsValid() } //--------------------------------------------------------------------------------------------------------------------- -bool DialogDetail::FirstPointEqualLast() +bool DialogDetail::FirstPointEqualLast() const { - const QString firstDetailPoint = ui.listWidget->item(0)->text(); - const QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text(); + if (ui.listWidget->count() > 1) + { + const QString firstDetailPoint = ui.listWidget->item(0)->text(); + const QString lastDetailPoint = ui.listWidget->item(ui.listWidget->count()-1)->text(); - if (QString::compare(firstDetailPoint, lastDetailPoint) == 0) - { - return true; - } - else - { - return false; + if (QString::compare(firstDetailPoint, lastDetailPoint) == 0) + { + return true; + } + else + { + return false; + } } + return false; } diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.h b/src/libs/vtools/dialogs/tools/dialogdetail.h index 7e3463175..dac43f320 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.h +++ b/src/libs/vtools/dialogs/tools/dialogdetail.h @@ -74,8 +74,8 @@ private: /** @brief closed keep option about equdistant (closed or not) */ bool closed; bool flagWidth; - bool DetailIsValid(); - bool FirstPointEqualLast(); + bool DetailIsValid() const; + bool FirstPointEqualLast() const; void NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode, qreal mx = 0, qreal my = 0, bool reverse = false);