From 47847a5a578a60e9ee03fa3f787975ee5f09965d Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 28 Aug 2018 23:34:55 +0100 Subject: [PATCH] Fix an assert in debug mode --- src/GUI/AircraftModel.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/GUI/AircraftModel.cxx b/src/GUI/AircraftModel.cxx index b1a8443de..ad5c0130b 100644 --- a/src/GUI/AircraftModel.cxx +++ b/src/GUI/AircraftModel.cxx @@ -652,13 +652,15 @@ void AircraftItemModel::onScanAddedItems(int addedCount) void AircraftItemModel::onLocalCacheCleared() { - const int firstRow = 0; - const int lastRow = m_cachedLocalAircraftCount + 1; + if (m_cachedLocalAircraftCount > 0) { + const int firstRow = 0; + const int lastRow = m_cachedLocalAircraftCount - 1; - beginRemoveRows(QModelIndex(), firstRow, lastRow); - m_delegateStates.remove(0, m_cachedLocalAircraftCount); - m_cachedLocalAircraftCount = 0; - endRemoveRows(); + beginRemoveRows(QModelIndex(), firstRow, lastRow); + m_delegateStates.remove(0, m_cachedLocalAircraftCount); + m_cachedLocalAircraftCount = 0; + endRemoveRows(); + } } void AircraftItemModel::installFailed(QModelIndex index, simgear::pkg::Delegate::StatusCode reason)