fpicker/source/office/PlacesListBox.cxx | 14 +++++++++----- fpicker/source/office/PlacesListBox.hxx | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-)
New commits: commit 2cce75357261aa3439d330e52df968ed5987da29 Author: Caolán McNamara <[email protected]> AuthorDate: Wed Dec 24 00:15:28 2025 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Dec 24 03:16:39 2025 +0100 cid#1677826 silence Argument cannot be negative and cid#1677825 Argument cannot be negative cid#1677824 Argument cannot be negative Change-Id: I7be698d1950574765c5c5e5e45b8ea92a403bb0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196184 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/fpicker/source/office/PlacesListBox.cxx b/fpicker/source/office/PlacesListBox.cxx index c8e815969879..6b93b8aede0d 100644 --- a/fpicker/source/office/PlacesListBox.cxx +++ b/fpicker/source/office/PlacesListBox.cxx @@ -56,9 +56,9 @@ bool PlacesListBox::IsUpdated() { return false; } -void PlacesListBox::RemovePlace( sal_uInt16 nPos ) +void PlacesListBox::RemovePlace(int nPos) { - if ( nPos < maPlaces.size() ) + if (nPos >= 0 && o3tl::make_unsigned(nPos) < maPlaces.size()) { if(maPlaces[nPos]->IsEditable()) { --mnNbEditables; @@ -98,7 +98,8 @@ OUString PlacesListBox::getEntryIcon( const PlacePtr& pPlace ) IMPL_LINK_NOARG( PlacesListBox, Selection, weld::TreeView&, void ) { - sal_uInt32 nSelected = mxImpl->get_cursor_index(); + int nSelected = mxImpl->get_cursor_index(); + assert(nSelected != -1 && "no selection"); PlacePtr pPlace = maPlaces[nSelected]; if (pPlace->IsEditable()) @@ -111,7 +112,9 @@ IMPL_LINK_NOARG( PlacesListBox, Selection, weld::TreeView&, void ) IMPL_LINK_NOARG( PlacesListBox, DoubleClick, weld::TreeView&, bool ) { - sal_uInt16 nSelected = mxImpl->get_cursor_index(); + int nSelected = mxImpl->get_cursor_index(); + if (nSelected == -1) + return true; PlacePtr pPlace = maPlaces[nSelected]; if ( !pPlace->IsEditable() || pPlace->IsLocal( ) ) return true; @@ -150,7 +153,8 @@ IMPL_LINK(PlacesListBox, QueryTooltipHdl, const weld::TreeIter&, rIter, OUString void PlacesListBox::updateView( ) { - sal_uInt32 nSelected = mxImpl->get_cursor_index(); + int nSelected = mxImpl->get_cursor_index(); + assert(nSelected != -1 && "no selection"); PlacePtr pPlace = maPlaces[nSelected]; mpDlg->OpenURL_Impl( pPlace->GetUrl( ) ); } diff --git a/fpicker/source/office/PlacesListBox.hxx b/fpicker/source/office/PlacesListBox.hxx index 3aabdb5aed14..0251cd29a42b 100644 --- a/fpicker/source/office/PlacesListBox.hxx +++ b/fpicker/source/office/PlacesListBox.hxx @@ -40,7 +40,7 @@ public: ~PlacesListBox(); void AppendPlace( const PlacePtr& pPlace ); - void RemovePlace( sal_uInt16 nPos ); + void RemovePlace( int nPos ); void RemoveSelectedPlace(); sal_Int32 GetNbEditablePlaces() const { return mnNbEditables;} bool IsUpdated();
