diff --git a/qutebrowser/app.py b/qutebrowser/app.py index c9b002260..3e3dd6cf1 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -238,6 +238,7 @@ class QuteBrowser(QApplication): logging.debug("maybe_quit called from {}, quit status {}".format( sender, self._quit_status)) if all(self._quit_status.values()): + logging.debug("maybe_quit quitting.") self.quit() def _python_hacks(self): @@ -328,7 +329,8 @@ class QuteBrowser(QApplication): logging.exception("Could not save window geometry.") try: if do_quit: - self.mainwindow.tabs.shutdown_complete.connect(self.quit) + self.mainwindow.tabs.shutdown_complete.connect( + self._on_tab_shutdown_complete) else: self.mainwindow.tabs.shutdown_complete.connect( functools.partial(self._maybe_quit, 'shutdown')) @@ -350,6 +352,16 @@ class QuteBrowser(QApplication): config.state['mainwindow']['w'] = str(rect.width()) config.state['mainwindow']['h'] = str(rect.height()) + @pyqtSlot() + def _on_tab_shutdown_complete(self): + """Quit application after a shutdown. + + Gets called when all tabs finished shutting down after shutdown(). + + """ + logging.debug("Shutdown complete, quitting.") + self.quit() + @pyqtSlot(tuple) def cmd_handler(self, tpl): """Handle commands and delegate the specific actions. diff --git a/qutebrowser/widgets/browser.py b/qutebrowser/widgets/browser.py index 9c90b62d8..14d2e9d9f 100644 --- a/qutebrowser/widgets/browser.py +++ b/qutebrowser/widgets/browser.py @@ -171,9 +171,10 @@ class TabbedBrowser(TabWidget): try: self._tabs.remove(tab) except ValueError: - logging.error("tab {} could not be removed from tabs {}.".format( - tab, self._tabs)) + logging.exception("tab {} could not be removed".format(tab)) + logging.debug("Tabs after removing: {}".format(self._tabs)) if not self._tabs: # all tabs shut down + logging.debug("Tab shutdown complete.") self.shutdown_complete.emit() def cur_reload(self, count=None): @@ -451,12 +452,12 @@ class TabbedBrowser(TabWidget): except TypeError: pass tabcount = self.count() - logging.debug("Shutting down {} tabs...".format(tabcount)) if tabcount == 0: + logging.debug("No tabs -> shutdown complete") self.shutdown_complete.emit() return for tabidx in range(tabcount): - logging.debug("shutdown {}".format(tabidx)) + logging.debug("Shutting down tab {}/{}".format(tabidx, tabcount)) tab = self.widget(tabidx) tab.shutdown(callback=functools.partial(self._cb_tab_shutdown, tab)) @@ -574,13 +575,18 @@ class BrowserTab(QWebView): netman.abort_requests() netman.destroyed.connect(functools.partial(self.on_destroyed, netman)) netman.deleteLater() - logging.debug("Shutdown scheduled") + logging.debug("Tab shutdown scheduled") def on_destroyed(self, sender): """Called when a subsystem has been destroyed during shutdown.""" self._destroyed[sender] = True + dbgout = '\n'.join(['{}: {}'.format(k.__class__.__name__, v) + for (k, v) in self._destroyed.items()]) + logging.debug("{} has been destroyed, new status:\n{}".format( + sender.__class__.__name__, dbgout)) if all(self._destroyed.values()): if self._shutdown_callback is not None: + logging.debug("Everything destroyed, calling callback") self._shutdown_callback() def eventFilter(self, watched, e):