From 2a744a4cf9ea8dafa6606aaf1c903a88fde4f3a6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 15 Aug 2014 13:32:59 +0530 Subject: [PATCH] Workaround for Qt 5 bug that causes the incorrect item to be selected when pressing the Enter key in the completion popup for search boxes. https://bugreports.qt-project.org/browse/QTBUG-40807 --- src/calibre/gui2/search_box.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 6eadccf57f..7e6b984ae5 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -85,10 +85,10 @@ class SearchBox2(QComboBox): # {{{ c = self.line_edit.completer() c.setCompletionMode(c.PopupCompletion) c.highlighted[str].connect(self.completer_used) - c.activated[str].connect(self.history_selected) self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection) - self.activated[str].connect(self.history_selected) + # QueuedConnection as workaround for https://bugreports.qt-project.org/browse/QTBUG-40807 + self.activated[str].connect(self.history_selected, type=Qt.QueuedConnection) self.setEditable(True) self.as_you_type = True self.timer = QTimer() @@ -245,7 +245,8 @@ class SearchBox2(QComboBox): # {{{ self.focus_to_library.emit() finally: if not store_in_history: - self.activated[str].connect(self.history_selected) + # QueuedConnection as workaround for https://bugreports.qt-project.org/browse/QTBUG-40807 + self.activated[str].connect(self.history_selected, type=Qt.QueuedConnection) def search_as_you_type(self, enabled): self.as_you_type = enabled