diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-02-17 12:29:22 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-02-18 11:22:29 +0100 |
commit | 563dc357fbe63f90552323bcc705e6cff4c9bd51 (patch) | |
tree | 7fdfe87e82f37cdb2540813809f5cc19f63ea7bb /src | |
parent | a54177cb940dc1d11d1591621edfe3ed42b0d778 (diff) |
Fix misguided conditional, simplify code
Prompted by a PVS-studio article.
The count <= 0 check made a later !count check redundant.
Change-Id: I6c00ad6137b14db13c9c31c61833b4546f663072
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/sql/models/qsqltablemodel.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index cb5026eb79..570101289c 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtSql module of the Qt Toolkit. @@ -1103,12 +1103,8 @@ bool QSqlTableModel::removeColumns(int column, int count, const QModelIndex &par bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent) { Q_D(QSqlTableModel); - if (parent.isValid() || row < 0 || count <= 0) + if (parent.isValid() || row < 0 || count <= 0 || row + count > rowCount()) return false; - else if (row + count > rowCount()) - return false; - else if (!count) - return true; if (d->strategy != OnManualSubmit) if (count > 1 || (d->cache.value(row).submitted() && isDirty())) |