From 387d0e3be65298cd2305be97563c215c6d3f7747 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 23 Apr 2014 14:34:00 +0200 Subject: [PATCH] Document hint lastChild() hack --- THANKS | 3 ++- qutebrowser/browser/hints.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 6273bb206..d5230912a 100644 --- a/THANKS +++ b/THANKS @@ -25,9 +25,10 @@ valuable ones: - chelmuth - quark - Bleeding Fingers + - artyom.stv Thanks to these people for helpful bits and pieces in the Qt bugtracker and IRC -channel: +channels: - Allan Sandfeld Jensen - bachewii - Vitaliy Filippov diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 5279d3a38..00cbf8141 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -266,6 +266,11 @@ class HintManager(QObject): css = self.HINT_CSS.format(left=rect.x(), top=rect.y(), config=config.instance) doc = self._frame.documentElement() + # It seems impossible to create an empty QWebElement for which isNull() + # is false so we can work with it. + # As a workaround, we use appendInside() with markup as argument, and + # then use lastChild() to get a reference to it. + # See: http://stackoverflow.com/q/7364852/2085149 doc.appendInside('{}'.format( css, string)) return doc.lastChild()