Bug#529435: QListBox::current set in insertItem without currentChanged emiting
On Tue, May 19, 2009 at 01:17:24PM +0200, Michal Hocko wrote:
> Package: qt-x11-free
> Severity: normal
>
> Hi,
> I have just noticed that buggy behavior in my application is caused by
> QListBox::current being set during insertItem without triggering currentChanged.
> My application uses currentChanged handler for enable/disable logic and
> so this doesn't work in case that box was empty.
>
> I am not sure whether this is correct or not, but it is at least
> inconsistent for cases like:
>
> box->insertItem(item, pos);
> box->setCurrentItem(pos);
>
> because this will trigger currentChanged signal only if box wasn't empty
> before.
>
> I have checked the source and really QListBox::insertItem does something
> like:
>
> if ( hasFocus() && !d->current ) {
> d->current = d->head;
> updateItem( d->current );
> emit highlighted( d->current );
> emit highlighted( d->current->text() );
> emit highlighted( index );
> }
>
> I think that we are missing emit currentChanged there.
I forgot to say that setCurrentItem after insertItem doesn't trigger
currentChanged because the setCurrentItem returns immediately if the
current is same as the given one which is exactly the case here.
--
Michal Hocko
Reply to: