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

index 1fd36821b04f9d831094ce79493a104bfe686a8f..edeaf74d5a471537654674785a71a343ecb43cf7 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 15b0942a99b6923a49af940affd40eb7a5395972..02dd790aea0d0fc0528c39ae59be5b9e26a8c30e 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 2ba46eb0039a4090fe60b55c81e9adea89f3051f..76a82fec03128aa91bc63ce2d0221676c6b2f7eb 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];