Skip to content

Commit efa0224

Browse files
committed
Remove possible recursive call of rawSiblingValue()
1 parent d0b5d94 commit efa0224

3 files changed

Lines changed: 7 additions & 23 deletions

File tree

src/library/basesqltablemodel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class BaseSqlTableModel : public BaseTrackTableModel {
9797

9898
TrackCollectionManager* const m_pTrackCollectionManager;
9999

100-
protected:
101100
QList<TrackRef> getTrackRefs(const QModelIndexList& indices) const;
102101

103102
QSqlDatabase m_database;

src/library/basetracktablemodel.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,6 @@ QVariant BaseTrackTableModel::data(
462462
return roleValue(index, rawValue(index), role);
463463
}
464464

465-
QVariant BaseTrackTableModel::rawValue(
466-
const QModelIndex& index) const {
467-
VERIFY_OR_DEBUG_ASSERT(index.isValid()) {
468-
return QVariant();
469-
}
470-
const auto field = mapColumn(index.column());
471-
if (field == ColumnCache::COLUMN_LIBRARYTABLE_INVALID) {
472-
return QVariant();
473-
}
474-
return rawSiblingValue(index, field);
475-
}
476-
477465
QVariant BaseTrackTableModel::rawSiblingValue(
478466
const QModelIndex& index,
479467
ColumnCache::Column siblingField) const {
@@ -483,13 +471,13 @@ QVariant BaseTrackTableModel::rawSiblingValue(
483471
VERIFY_OR_DEBUG_ASSERT(siblingField != ColumnCache::COLUMN_LIBRARYTABLE_INVALID) {
484472
return QVariant();
485473
}
486-
const auto siblingColumn = fieldIndex(siblingField);
474+
const int siblingColumn = fieldIndex(siblingField);
487475
if (siblingColumn < 0) {
488476
// Unsupported or unknown column/field
489477
// FIXME: This should never happen but it does. But why??
490478
return QVariant();
491479
}
492-
const auto siblingIndex = index.sibling(index.row(), siblingColumn);
480+
const QModelIndex siblingIndex = index.sibling(index.row(), siblingColumn);
493481
return rawValue(siblingIndex);
494482
}
495483

src/library/basetracktablemodel.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
162162
virtual Qt::ItemFlags readWriteFlags(
163163
const QModelIndex& index) const;
164164

165-
/// At least one of the following functions must be overridden,
166-
/// because each default implementation will call the other
167-
/// function!!
168-
///
169165
/// Return the raw data value at the given index.
170166
///
171167
/// Expected types by ColumnCache field (pass-through = not validated):
@@ -211,10 +207,7 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
211207
/// COLUMN_LIBRARYTABLE_LAST_PLAYED_AT: QDateTime
212208
/// COLUMN_PLAYLISTTABLE_DATETIMEADDED: QDateTime
213209
virtual QVariant rawValue(
214-
const QModelIndex& index) const;
215-
virtual QVariant rawSiblingValue(
216-
const QModelIndex& index,
217-
ColumnCache::Column siblingField) const;
210+
const QModelIndex& index) const = 0;
218211

219212
QVariant roleValue(
220213
const QModelIndex& index,
@@ -250,6 +243,10 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
250243
const QPixmap& pixmap);
251244

252245
private:
246+
QVariant rawSiblingValue(
247+
const QModelIndex& index,
248+
ColumnCache::Column siblingField) const;
249+
253250
// Track models may reference tracks by an external id
254251
// TODO: TrackId should only be used for tracks from
255252
// the internal database.

0 commit comments

Comments
 (0)