Shut down tabs while quitting

This commit is contained in:
Florian Bruhin 2014-07-31 20:40:21 +02:00
parent 55755262e1
commit 682a395936
3 changed files with 49 additions and 17 deletions

View File

@ -673,6 +673,9 @@ class Application(QApplication):
return return
self._shutting_down = True self._shutting_down = True
log.destroy.debug("Shutting down with status {}...".format(status)) log.destroy.debug("Shutting down with status {}...".format(status))
# Close all tabs
log.destroy.debug("Closing tabs...")
self.mainwindow.tabs.shutdown()
# Save everything # Save everything
if hasattr(self, 'config') and self.config is not None: if hasattr(self, 'config') and self.config is not None:
to_save = [] to_save = []

View File

@ -81,7 +81,11 @@ class SignalFilter(QObject):
The target signal if the sender was the current widget. The target signal if the sender was the current widget.
""" """
log_signal = signal_name(signal) not in self.BLACKLIST log_signal = signal_name(signal) not in self.BLACKLIST
try:
tabidx = self._tabs.indexOf(tab) tabidx = self._tabs.indexOf(tab)
except RuntimeError:
# The tab has been deleted already
return
if tabidx == self._tabs.currentIndex(): if tabidx == self._tabs.currentIndex():
if log_signal: if log_signal:
logger.debug("emitting: {} (tab {})".format( logger.debug("emitting: {} (tab {})".format(

View File

@ -223,7 +223,7 @@ class TabbedBrowser(TabWidget):
log.destroy.debug("Error while shutting down tabs: {}: {}".format( log.destroy.debug("Error while shutting down tabs: {}: {}".format(
e.__class__.__name__, e)) e.__class__.__name__, e))
for tab in self.widgets: for tab in self.widgets:
self._tabs.remove(tab) self._remove_tab(tab)
def close_tab(self, tab): def close_tab(self, tab):
"""Close a tab with either index or tab given. """Close a tab with either index or tab given.
@ -261,6 +261,7 @@ class TabbedBrowser(TabWidget):
if not url.isEmpty(): if not url.isEmpty():
qt_ensure_valid(url) qt_ensure_valid(url)
self.url_stack.append(url) self.url_stack.append(url)
tab.blockSignals(True)
self._tabs.remove(tab) self._tabs.remove(tab)
self.removeTab(idx) self.removeTab(idx)
tab.deleteLater() tab.deleteLater()
@ -366,7 +367,11 @@ class TabbedBrowser(TabWidget):
Args: Args:
tab: The tab where the signal belongs to. tab: The tab where the signal belongs to.
""" """
try:
idx = self.indexOf(tab) idx = self.indexOf(tab)
except RuntimeError:
# We can get signals for tabs we already deleted...
return
if idx == -1: if idx == -1:
# We can get signals for tabs we already deleted... # We can get signals for tabs we already deleted...
log.webview.debug("Got invalid tab {}!".format(tab)) log.webview.debug("Got invalid tab {}!".format(tab))
@ -389,8 +394,14 @@ class TabbedBrowser(TabWidget):
text: The text to set. text: The text to set.
""" """
log.webview.debug("title changed to '{}'".format(text)) log.webview.debug("title changed to '{}'".format(text))
if text: if not text:
log.webview.debug("ignoring title change")
return
try:
idx = self.indexOf(tab) idx = self.indexOf(tab)
except RuntimeError:
# We can get signals for tabs we already deleted...
return
if idx == -1: if idx == -1:
# We can get signals for tabs we already deleted... # We can get signals for tabs we already deleted...
log.webview.debug("Got invalid tab {}!".format(tab)) log.webview.debug("Got invalid tab {}!".format(tab))
@ -398,8 +409,6 @@ class TabbedBrowser(TabWidget):
self.setTabText(idx, text) self.setTabText(idx, text)
if idx == self.currentIndex(): if idx == self.currentIndex():
self.title_changed.emit('{} - qutebrowser'.format(text)) self.title_changed.emit('{} - qutebrowser'.format(text))
else:
log.webview.debug("ignoring title change")
@pyqtSlot(WebView, str) @pyqtSlot(WebView, str)
def on_url_text_changed(self, tab, url): def on_url_text_changed(self, tab, url):
@ -409,7 +418,11 @@ class TabbedBrowser(TabWidget):
tab: The WebView where the title was changed. tab: The WebView where the title was changed.
url: The new URL. url: The new URL.
""" """
try:
idx = self.indexOf(tab) idx = self.indexOf(tab)
except RuntimeError:
# We can get signals for tabs we already deleted...
return
if idx == -1: if idx == -1:
# We can get signals for tabs we already deleted... # We can get signals for tabs we already deleted...
log.webview.debug("Got invalid tab {}!".format(tab)) log.webview.debug("Got invalid tab {}!".format(tab))
@ -428,7 +441,11 @@ class TabbedBrowser(TabWidget):
""" """
if not config.get('tabbar', 'show-favicons'): if not config.get('tabbar', 'show-favicons'):
return return
try:
idx = self.indexOf(tab) idx = self.indexOf(tab)
except RuntimeError:
# We can get signals for tabs we already deleted...
return
if idx == -1: if idx == -1:
# We can get *_changed signals for tabs we already deleted... # We can get *_changed signals for tabs we already deleted...
log.webview.debug("Got invalid tab {}!".format(tab)) log.webview.debug("Got invalid tab {}!".format(tab))
@ -454,7 +471,11 @@ class TabbedBrowser(TabWidget):
def on_load_progress(self, tab, perc): def on_load_progress(self, tab, perc):
"""Adjust tab indicator on load progress.""" """Adjust tab indicator on load progress."""
try:
idx = self.indexOf(tab) idx = self.indexOf(tab)
except RuntimeError:
# We can get signals for tabs we already deleted...
return
start = config.get('colors', 'tab.indicator.start') start = config.get('colors', 'tab.indicator.start')
stop = config.get('colors', 'tab.indicator.stop') stop = config.get('colors', 'tab.indicator.stop')
system = config.get('colors', 'tab.indicator.system') system = config.get('colors', 'tab.indicator.system')
@ -463,7 +484,11 @@ class TabbedBrowser(TabWidget):
def on_load_finished(self, tab, ok): def on_load_finished(self, tab, ok):
"""Adjust tab indicator when loading finished.""" """Adjust tab indicator when loading finished."""
try:
idx = self.indexOf(tab) idx = self.indexOf(tab)
except RuntimeError:
# We can get signals for tabs we already deleted...
return
if ok: if ok:
start = config.get('colors', 'tab.indicator.start') start = config.get('colors', 'tab.indicator.start')
stop = config.get('colors', 'tab.indicator.stop') stop = config.get('colors', 'tab.indicator.stop')