From 5f9c56bcdd88ea40c22aecb58236a45bcc190672 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 9 Nov 2014 22:57:39 +0100 Subject: [PATCH] Fix exception when logging Qt warning without function. --- qutebrowser/utils/log.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index f88c406b8..c9bbf08d9 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -266,13 +266,17 @@ def qt_message_handler(msg_type, context, msg): level = logging.DEBUG else: level = qt_to_logging[msg_type] - # We get something like "void qt_png_warning(png_structp, png_const_charp)" - # from Qt, but only want "qt_png_warning". - match = re.match(r'.*( |::)(\w*)\(.*\)', context.function) - if match is not None: - func = match.group(2) + if context.function is None: + func = 'none' else: - func = context.function + # We get something like + # "void qt_png_warning(png_structp, png_const_charp)" from Qt, but only + # want "qt_png_warning". + match = re.match(r'.*( |::)(\w*)\(.*\)', context.function) + if match is not None: + func = match.group(2) + else: + func = context.function name = 'qt' if context.category == 'default' else 'qt-' + context.category if msg.splitlines()[0] == ('This application failed to start because it ' 'could not find or load the Qt platform plugin '