First fix for :restart

This commit is contained in:
Florian Bruhin 2014-06-24 06:43:52 +02:00
parent 43bcb2a746
commit 65353773d1

View File

@ -21,6 +21,7 @@
import os import os
import sys import sys
import subprocess
import faulthandler import faulthandler
import configparser import configparser
from bdb import BdbQuit from bdb import BdbQuit
@ -84,7 +85,6 @@ class Application(QApplication):
_timers: List of used QTimers so they don't get GCed. _timers: List of used QTimers so they don't get GCed.
_shutting_down: True if we're currently shutting down. _shutting_down: True if we're currently shutting down.
_quit_status: The current quitting status. _quit_status: The current quitting status.
_opened_urls: List of opened URLs, string as passed to the application.
_crashdlg: The crash dialog currently open. _crashdlg: The crash dialog currently open.
_crashlogfile: A file handler to the fatal crash logfile. _crashlogfile: A file handler to the fatal crash logfile.
""" """
@ -109,7 +109,6 @@ class Application(QApplication):
'main': False, 'main': False,
} }
self._timers = [] self._timers = []
self._opened_urls = []
self._shutting_down = False self._shutting_down = False
self._keyparsers = None self._keyparsers = None
self._crashdlg = None self._crashdlg = None
@ -312,7 +311,6 @@ class Application(QApplication):
self.commandmanager.run_safely_init(cmd.lstrip(':')) self.commandmanager.run_safely_init(cmd.lstrip(':'))
else: else:
log.init.debug("Startup URL {}".format(cmd)) log.init.debug("Startup URL {}".format(cmd))
self._opened_urls.append(cmd)
try: try:
url = urlutils.fuzzy_url(cmd) url = urlutils.fuzzy_url(cmd)
except urlutils.FuzzyUrlError as e: except urlutils.FuzzyUrlError as e:
@ -582,32 +580,36 @@ class Application(QApplication):
log.destroy.debug("maybe_quit quitting.") log.destroy.debug("maybe_quit quitting.")
self.quit() self.quit()
#@cmdutils.register(instance='', nargs=0) @cmdutils.register(instance='', nargs=0)
#def restart(self, shutdown=True, pages=None): def restart(self, shutdown=True, pages=None):
# """Restart qutebrowser while keeping existing tabs open.""" """Restart qutebrowser while keeping existing tabs open."""
# # We don't use _recover_pages here as it's too forgiving when # We don't use _recover_pages here as it's too forgiving when
# # exceptions occur. # exceptions occur.
# if pages is None: if pages is None:
# pages = [] pages = []
# for tab in self.mainwindow.tabs.widgets: for tab in self.mainwindow.tabs.widgets:
# urlstr = tab.url().toString() urlstr = tab.url().toString()
# if urlstr: if urlstr:
# pages.append(urlstr) pages.append(urlstr)
# pythonpath = os.pathsep.join(sys.path) path = os.path.join(os.path.abspath(os.path.dirname(
# os.environ['PYTHONPATH'] = pythonpath qutebrowser.__file__)), '..')
# argv = sys.argv[:] log.destroy.debug("path: {}".format(path))
# for page in self._opened_urls: log.destroy.debug("sys.executable: {}".format(sys.executable))
# try: log.destroy.debug("sys.path: {}".format(sys.path))
# argv.remove(page) log.destroy.debug("sys.argv: {}".format(sys.argv))
# except ValueError as e: log.destroy.debug("frozen: {}".format(hasattr(sys, 'frozen')))
# logger.destroy.debug("Error while removing page: {}: " args = [sys.executable, '-m', 'qutebrowser']
# "{}".format(e.__class__.__name__, e)) for arg in sys.argv[1:]:
# argv = [sys.executable] + argv + pages if arg.startswith('-'):
# log.procs.debug("Running {} with args {} (PYTHONPATH={})".format( # We only want to preserve options on a restart.
# sys.executable, argv, pythonpath)) args.append(arg)
# subprocess.Popen(argv) # Add all open pages so they get reopened.
# if shutdown: args += pages
# self.shutdown() log.destroy.debug("final args: {}".format(args))
# Open a new process and immediately shutdown the existing one
subprocess.Popen(args, cwd=path)
if shutdown:
self.shutdown()
@cmdutils.register(instance='', split=False, debug=True) @cmdutils.register(instance='', split=False, debug=True)
def debug_pyeval(self, s): def debug_pyeval(self, s):