Skip to content

Commit bbb9485

Browse files
committed
More thorough fix for wrong rowCount() functions
1 parent ad45a96 commit bbb9485

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/amidiplug/i_configure-fluidsynth.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,11 @@ class SoundFontListModel : public QAbstractListModel
311311
~SoundFontListModel ();
312312

313313
protected:
314-
int rowCount (const QModelIndex &) const { return m_file_names.len (); }
314+
int rowCount (const QModelIndex & parent) const
315+
{
316+
return parent.isValid() ? 0 : m_file_names.len();
317+
}
318+
315319
int columnCount (const QModelIndex &) const { return NColumns; }
316320
QVariant data (const QModelIndex & index, int role) const;
317321
QVariant headerData (int section, Qt::Orientation, int role) const;

src/playlist-manager-qt/playlist-manager-qt.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ class PlaylistsModel : public QAbstractListModel
8080
void update (Playlist::UpdateLevel level);
8181

8282
protected:
83-
int rowCount (const QModelIndex & parent) const { return m_rows; }
83+
int rowCount (const QModelIndex & parent) const
84+
{
85+
return parent.isValid() ? 0 : m_rows;
86+
}
87+
8488
int columnCount (const QModelIndex & parent) const { return NColumns; }
8589

8690
Qt::DropActions supportedDropActions () const { return Qt::MoveAction; }

src/qtui/playlist_model.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ PlaylistModel::PlaylistModel(QObject * parent, Playlist playlist)
5656

5757
int PlaylistModel::rowCount(const QModelIndex & parent) const
5858
{
59-
return (parent == QModelIndex()) ? m_rows : 0;
59+
return parent.isValid() ? 0 : m_rows;
6060
}
6161

6262
int PlaylistModel::columnCount(const QModelIndex & parent) const

src/search-tool-qt/search-model.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ class SearchModel : public QAbstractListModel
7676
void do_search (const Index<String> & terms, int max_results);
7777

7878
protected:
79-
int rowCount (const QModelIndex & parent) const { return m_rows; }
79+
int rowCount (const QModelIndex & parent) const
80+
{
81+
return parent.isValid() ? 0 : m_rows;
82+
}
83+
8084
int columnCount (const QModelIndex & parent) const { return 1; }
8185
QVariant data (const QModelIndex & index, int role) const;
8286

0 commit comments

Comments
 (0)