[vlc-devel] [PATCH 2/9] qt: add bound checking to selected setters in SelectableListModel
Romain Vimont
rom1v at videolabs.io
Tue Nov 19 09:51:57 CET 2019
IMO this is an error to call setSelected() or isSelected() with an
invalid index, so I think that assertions would be more appropriate.
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