summary refs log tree commit diff
path: root/src/timeline/TimelineModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-10-20 19:40:53 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-10-20 19:40:53 +0200
commit071578923d4b9bb164edae171e6513dfe7085a98 (patch)
tree57c4e9d8bb2fbbdecc53e33c83ec7c56cf968f9c /src/timeline/TimelineModel.cpp
parentSmall qml fixes (diff)
downloadnheko-071578923d4b9bb164edae171e6513dfe7085a98.tar.xz
Possibly fix a crash in the EventDelegateChooser
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r--src/timeline/TimelineModel.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index e8b5d40e..e8a0a507 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -989,8 +989,11 @@ TimelineModel::data(const QModelIndex &index, int role) const void TimelineModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const { - if (index.row() < 0 && index.row() >= rowCount()) + if (index.row() < 0 && index.row() >= rowCount()) { + for (QModelRoleData &roleData : roleDataSpan) + roleData.clearData(); return; + } // HACK(Nico): fetchMore likes to break with dynamically sized delegates and reuseItems if (index.row() + 1 == rowCount() && !m_paginationInProgress) @@ -998,13 +1001,14 @@ TimelineModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSp auto event = events.get(rowCount() - index.row() - 1); - if (!event) + if (!event) { + for (QModelRoleData &roleData : roleDataSpan) + roleData.clearData(); return; + } for (QModelRoleData &roleData : roleDataSpan) { - int role = roleData.role(); - - roleData.setData(data(*event, role)); + roleData.setData(data(*event, roleData.role())); } } @@ -1013,13 +1017,19 @@ TimelineModel::multiData(const QString &id, const QString &relatedTo, QModelRoleDataSpan roleDataSpan) const { - if (id.isEmpty()) + if (id.isEmpty()) { + for (QModelRoleData &roleData : roleDataSpan) + roleData.clearData(); return; + } auto event = events.get(id.toStdString(), relatedTo.toStdString()); - if (!event) + if (!event) { + for (QModelRoleData &roleData : roleDataSpan) + roleData.clearData(); return; + } for (QModelRoleData &roleData : roleDataSpan) { int role = roleData.role();