From: Mikko Rasa Date: Wed, 16 Oct 2013 12:04:49 +0000 (+0300) Subject: Make List::set_selected_index a no-op if that item was already selected X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d155c3559f7801825a2326b4186b3c7d18c23214;p=libs%2Fgltk.git Make List::set_selected_index a no-op if that item was already selected --- diff --git a/source/list.cpp b/source/list.cpp index b712574..653a40c 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -141,11 +141,14 @@ void List::set_selected_index(int i) if(i>=static_cast(data->size())) throw out_of_range("List::set_selected_index"); + if(i==sel_index) + return; + if(sel_index>=0) items[sel_index]->set_active(false); if(i<0) sel_index = -1; - else if(i!=sel_index) + else { sel_index = i; items[sel_index]->set_active(true);