From f6d4e0d32c766959b96a4760d55c6d15bf1c86bb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 10 Aug 2016 13:58:41 +0200 Subject: [PATCH] Try working around AttributeError in objreg --- qutebrowser/utils/objreg.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/qutebrowser/utils/objreg.py b/qutebrowser/utils/objreg.py index d347b7756..0691be1ee 100644 --- a/qutebrowser/utils/objreg.py +++ b/qutebrowser/utils/objreg.py @@ -94,8 +94,15 @@ class ObjectRegistry(collections.UserDict): def _disconnect_destroyed(self, name): """Disconnect the destroyed slot if it was connected.""" - if name in self._partial_objs: - func = self._partial_objs[name] + try: + partial_objs = self._partial_objs + except AttributeError: + # This sometimes seems to happen on Travis during + # test_history.test_adding_item_during_async_read + # and I have no idea why... + return + if name in partial_objs: + func = partial_objs[name] try: self[name].destroyed.disconnect(func) except (RuntimeError, TypeError): @@ -106,7 +113,7 @@ class ObjectRegistry(collections.UserDict): # pyqtSignal must be bound to a QObject" instead: # https://github.com/The-Compiler/qutebrowser/issues/257 pass - del self._partial_objs[name] + del partial_objs[name] def on_destroyed(self, name): """Schedule removing of a destroyed QObject.