[vlc-commits] Qt: fix improper dataChanged() signal emission
Erwan Tulou
git at videolan.org
Mon Sep 23 13:39:32 CEST 2019
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Sep 22 22:05:07 2019 +0200| [a1c19dde82e31344a109ccb59b727d4649f78cd0] | committer: Thomas Guillem
Qt: fix improper dataChanged() signal emission
At https://doc.qt.io/qt-5/qabstractitemmodel.html#dataChanged, it reads:
"This signal is emitted whenever the data in an existing item changes."
My understanding is that emitting dataChanged() is limited to the update of
an existing item. Neither insertion nor deletion of an item have to emit
this signal.
Furthermore, in the case of deletion, this may lead to the following error:
ASSERT failure in QList<T>::operator[]: "index out of range", file /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 549
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a1c19dde82e31344a109ccb59b727d4649f78cd0
---
modules/gui/qt/util/input_models.cpp | 4 ----
1 file changed, 4 deletions(-)
diff --git a/modules/gui/qt/util/input_models.cpp b/modules/gui/qt/util/input_models.cpp
index 8c795df1ef..f344e8b7f1 100644
--- a/modules/gui/qt/util/input_models.cpp
+++ b/modules/gui/qt/util/input_models.cpp
@@ -83,8 +83,6 @@ void TrackListModel::updateTracks(vlc_player_list_action action, const vlc_playe
beginInsertRows({}, m_data.size(), m_data.size());
m_data.append(Data{ track_info });
endInsertRows();
- QModelIndex dataIndex = index(m_data.size() - 1);
- emit dataChanged(dataIndex, dataIndex);
break;
}
case VLC_PLAYER_LIST_REMOVED:
@@ -99,8 +97,6 @@ void TrackListModel::updateTracks(vlc_player_list_action action, const vlc_playe
beginRemoveRows({}, pos, pos);
m_data.erase(it);
endRemoveRows();
- QModelIndex dataIndex = index(pos);
- emit dataChanged(dataIndex, dataIndex);
break;
}
case VLC_PLAYER_LIST_UPDATED:
More information about the vlc-commits
mailing list