From 563dc357fbe63f90552323bcc705e6cff4c9bd51 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 17 Feb 2021 12:29:22 +0100 Subject: [PATCH] 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 Reviewed-by: Volker Hilsheimer --- src/sql/models/qsqltablemodel.cpp | 8 ++------ 1 file 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()))