]> git.tdb.fi Git - libs/gltk.git/commitdiff
Make List::set_selected_index a no-op if that item was already selected
authorMikko Rasa <tdb@tdb.fi>
Wed, 16 Oct 2013 12:04:49 +0000 (15:04 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 16 Oct 2013 12:04:49 +0000 (15:04 +0300)
source/list.cpp

index b712574d3992f9a0a5c3406837206e6ed1204542..653a40c92bc1195e7b75276a50f08fc37891ff29 100644 (file)
@@ -141,11 +141,14 @@ void List::set_selected_index(int i)
        if(i>=static_cast<int>(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);