]> Some of my projects - aniplayer.git/commitdiff
Make sure model indexes are valid
authorAPTX <redacted>
Sun, 26 Nov 2017 11:02:23 +0000 (20:02 +0900)
committerAPTX <redacted>
Sun, 26 Nov 2017 11:02:23 +0000 (20:02 +0900)
core/annotationmodel.cpp
core/chaptermodel.cpp
core/trackmodel.cpp

index 1fd3682..edeaf74 100644 (file)
@@ -29,6 +29,8 @@ int AnnotationModel::rowCount(const QModelIndex &parent) const {
 }
 
 QVariant AnnotationModel::data(const QModelIndex &index, int role) const {
+  if (!index.isValid())
+    return {};
 
   const PlayerFeaturePlauginInterface::Annotation &annotation =
       m_data.at(index.row());
index 15b0942..02dd790 100644 (file)
@@ -30,6 +30,9 @@ int ChapterModel::rowCount(const QModelIndex &parent) const {
 }
 
 QVariant ChapterModel::data(const QModelIndex &index, int role) const {
+  if (!index.isValid())
+    return {};
+
   switch (role) {
   case TitleRole:
   case Qt::DisplayRole:
index 2ba46eb..76a82fe 100644 (file)
@@ -27,6 +27,9 @@ int TrackModel::rowCount(const QModelIndex &parent) const {
 QVariant TrackModel::data(const QModelIndex &index, int role) const {
   static PlayerPluginInterface::Track noneTrackData{"None", "", -1};
 
+  if (!index.isValid())
+    return {};
+
   auto &trackData =
       (index.row() == 0) ? noneTrackData : m_data[index.row() - 1];