QCompleter: Add check before setting the widget

This prevents unnecessarily removing and reinstalling the completer
as event filter on the same widget.

This does not prevent what's going on in QComboBox::focusInEvent(),
where we'd set the line edit as widget just to immediately override
it with combo box itself.

Change-Id: I70c081a920f4daf4d7560e5cd7158e4070042d42
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Gabriel de Dietrich 2017-08-25 16:16:12 +07:00
parent db0585d63a
commit f1a857c079

View File

@ -1013,11 +1013,15 @@ QCompleter::~QCompleter()
void QCompleter::setWidget(QWidget *widget)
{
Q_D(QCompleter);
if (widget == d->widget)
return;
if (d->widget)
d->widget->removeEventFilter(this);
d->widget = widget;
if (d->widget)
d->widget->installEventFilter(this);
if (d->popup) {
d->popup->hide();
d->popup->setFocusProxy(d->widget);