Skip to content

Truly independent web browser

UI/Qt: Only filter application events for hosted autocomplete

Callum Lawb6b2d5d93ffa
diff --git a/UI/Qt/Autocomplete.cpp b/UI/Qt/Autocomplete.cpp
index 94cef24d396..256778a3b88 100644
--- a/UI/Qt/Autocomplete.cpp
+++ b/UI/Qt/Autocomplete.cpp
@@ -313,7 +313,6 @@ Autocomplete::Autocomplete(QLineEdit* anchor)
{
m_model = new AutocompleteModel(this);
m_delegate = new AutocompleteDelegate(this);
- qApp->installEventFilter(this);
}
QListView* Autocomplete::create_list_view(QWidget& parent)
@@ -344,10 +343,15 @@ void Autocomplete::set_host(QWidget* host)
return;
auto was_visible = close();
+ if (m_host)
+ disconnect(m_host, &QObject::destroyed, this, nullptr);
+ qApp->removeEventFilter(this);
delete m_list_view.data();
m_host = host;
if (host) {
+ qApp->installEventFilter(this);
+ connect(host, &QObject::destroyed, this, [this] { qApp->removeEventFilter(this); });
m_list_view = create_list_view(*host);
m_list_view->hide();
host->layout()->addWidget(m_list_view);