diff options
-rw-r--r-- | desktop-widgets/modeldelegates.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index e2774240f..11d42c36e 100644 --- a/desktop-widgets/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -217,9 +217,11 @@ void TankInfoDelegate::setModelData(QWidget *, QAbstractItemModel *, const QMode { QAbstractItemModel *mymodel = currCombo.model; TankInfoModel *tanks = TankInfoModel::instance(); - QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, currCombo.activeText, 1, Qt::MatchFixedString | Qt::MatchWrap); + QString cylinderName = currCombo.activeText.trimmed(); + if (cylinderName.isEmpty()) + return; + QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cylinderName, 1, Qt::MatchFixedString | Qt::MatchWrap); int row; - QString cylinderName = currCombo.activeText; if (matches.isEmpty()) { tanks->insertRows(tanks->rowCount(), 1); tanks->setData(tanks->index(tanks->rowCount() - 1, 0), currCombo.activeText); |