From 4362d42c505b5b7f9cff8ec55a54844b484d603d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Aug 2016 10:13:07 +0200 Subject: [PATCH] Add postpone argument to AbstractTab.send_event --- qutebrowser/browser/browsertab.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 66116b34c..d218deebc 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -566,11 +566,18 @@ class AbstractTab(QWidget): """Return the widget events should be sent to.""" raise NotImplementedError - def send_event(self, evt): - """Send the given event to the underlying widget.""" - recipient = self._event_target() - QApplication.sendEvent(recipient, evt) + def send_event(self, evt, *, postpone=False): + """Send the given event to the underlying widget. + Args: + postpone: Postpone the event to be handled later instead of + immediately. Using this might cause crashes in Qt. + """ + recipient = self._event_target() + if postpone: + QApplication.postEvent(recipient, evt) + else: + QApplication.sendEvent(recipient, evt) @pyqtSlot(QUrl) def _on_link_clicked(self, url):