From d0b5d9489a7e7b18d69a8fa8d1611996bc69992f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 22 Apr 2024 21:28:32 +0200 Subject: [PATCH 1/2] Remove autdated ASSERT fixing #13164 --- src/library/basetracktablemodel.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 4fc2a5ab1e65..5a6401861c59 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -489,10 +489,6 @@ QVariant BaseTrackTableModel::rawSiblingValue( // FIXME: This should never happen but it does. But why?? return QVariant(); } - VERIFY_OR_DEBUG_ASSERT(siblingColumn != index.column()) { - // Prevent infinite recursion - return QVariant(); - } const auto siblingIndex = index.sibling(index.row(), siblingColumn); return rawValue(siblingIndex); } From efa0224a0445ef97efa611aa22a7cd84abb9b1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 31 Jul 2024 23:23:58 +0200 Subject: [PATCH 2/2] Remove possible recursive call of rawSiblingValue() --- src/library/basesqltablemodel.h | 1 - src/library/basetracktablemodel.cpp | 16 ++-------------- src/library/basetracktablemodel.h | 13 +++++-------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/library/basesqltablemodel.h b/src/library/basesqltablemodel.h index 711185600dd9..66a19b77a280 100644 --- a/src/library/basesqltablemodel.h +++ b/src/library/basesqltablemodel.h @@ -97,7 +97,6 @@ class BaseSqlTableModel : public BaseTrackTableModel { TrackCollectionManager* const m_pTrackCollectionManager; - protected: QList getTrackRefs(const QModelIndexList& indices) const; QSqlDatabase m_database; diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 5a6401861c59..cdfcdaf3490d 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -462,18 +462,6 @@ QVariant BaseTrackTableModel::data( return roleValue(index, rawValue(index), role); } -QVariant BaseTrackTableModel::rawValue( - const QModelIndex& index) const { - VERIFY_OR_DEBUG_ASSERT(index.isValid()) { - return QVariant(); - } - const auto field = mapColumn(index.column()); - if (field == ColumnCache::COLUMN_LIBRARYTABLE_INVALID) { - return QVariant(); - } - return rawSiblingValue(index, field); -} - QVariant BaseTrackTableModel::rawSiblingValue( const QModelIndex& index, ColumnCache::Column siblingField) const { @@ -483,13 +471,13 @@ QVariant BaseTrackTableModel::rawSiblingValue( VERIFY_OR_DEBUG_ASSERT(siblingField != ColumnCache::COLUMN_LIBRARYTABLE_INVALID) { return QVariant(); } - const auto siblingColumn = fieldIndex(siblingField); + const int siblingColumn = fieldIndex(siblingField); if (siblingColumn < 0) { // Unsupported or unknown column/field // FIXME: This should never happen but it does. But why?? return QVariant(); } - const auto siblingIndex = index.sibling(index.row(), siblingColumn); + const QModelIndex siblingIndex = index.sibling(index.row(), siblingColumn); return rawValue(siblingIndex); } diff --git a/src/library/basetracktablemodel.h b/src/library/basetracktablemodel.h index d8daf44ba22c..776067a31fa2 100644 --- a/src/library/basetracktablemodel.h +++ b/src/library/basetracktablemodel.h @@ -162,10 +162,6 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel { virtual Qt::ItemFlags readWriteFlags( const QModelIndex& index) const; - /// At least one of the following functions must be overridden, - /// because each default implementation will call the other - /// function!! - /// /// Return the raw data value at the given index. /// /// Expected types by ColumnCache field (pass-through = not validated): @@ -211,10 +207,7 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel { /// COLUMN_LIBRARYTABLE_LAST_PLAYED_AT: QDateTime /// COLUMN_PLAYLISTTABLE_DATETIMEADDED: QDateTime virtual QVariant rawValue( - const QModelIndex& index) const; - virtual QVariant rawSiblingValue( - const QModelIndex& index, - ColumnCache::Column siblingField) const; + const QModelIndex& index) const = 0; QVariant roleValue( const QModelIndex& index, @@ -250,6 +243,10 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel { const QPixmap& pixmap); private: + QVariant rawSiblingValue( + const QModelIndex& index, + ColumnCache::Column siblingField) const; + // Track models may reference tracks by an external id // TODO: TrackId should only be used for tracks from // the internal database.