[vlc-devel] [PATCH 2/9] qt: add bound checking to selected setters in SelectableListModel
Pierre Lamot
pierre at videolabs.io
Tue Nov 19 10:48:03 CET 2019
On 2019-11-19 09:51, Romain Vimont wrote:
> IMO this is an error to call setSelected() or isSelected() with an
> invalid index, so I think that assertions would be more appropriate.
hi,
sure, I updated my branch there
https://code.videolan.org/chub/vlc/commits/qt/qml-fixes
qt: add bound checking to selected setters in SelectableListModel
(https://code.videolan.org/chub/vlc/commit/594a2669eeed2b5f21f4b6975158eb7599d5e438)
qml: ensure bound checks while manipulating the playlist in PlaylistView
(https://code.videolan.org/chub/vlc/commit/e8615d9fb211e5f3290f4b2728684643cead0cd7)
> On 11/18/19 6:15 PM, Pierre Lamot wrote:
>> ---
>> modules/gui/qt/components/selectable_list_model.cpp | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/modules/gui/qt/components/selectable_list_model.cpp
>> b/modules/gui/qt/components/selectable_list_model.cpp
>> index cf6711761d..45a2c997ea 100644
>> --- a/modules/gui/qt/components/selectable_list_model.cpp
>> +++ b/modules/gui/qt/components/selectable_list_model.cpp
>> @@ -26,6 +26,9 @@ namespace vlc {
>> void SelectableListModel::setSelected(int row, bool selected)
>> {
>> + if (row < 0 || row >= rowCount())
>> + return;
>> +
>> setRowSelected(row, selected);
>> QModelIndex modelIndex = index(row);
>> @@ -35,11 +38,17 @@ void SelectableListModel::setSelected(int row,
>> bool selected)
>> bool SelectableListModel::isSelected(int row) const
>> {
>> + if (row < 0 || row >= rowCount())
>> + return false;
>> +
>> return isRowSelected(row);
>> }
>> void SelectableListModel::toggleSelected(int row)
>> {
>> + if (row < 0 || row >= rowCount())
>> + return;
>> +
>> setRowSelected(row, !isRowSelected(row));
>> QModelIndex modelIndex = index(row);
>>
More information about the vlc-devel
mailing list