parent
a1eb26c042
commit
041aa61508
@ -550,6 +550,10 @@ class Quitter:
|
|||||||
else:
|
else:
|
||||||
argdict['session'] = session
|
argdict['session'] = session
|
||||||
argdict['override_restore'] = False
|
argdict['override_restore'] = False
|
||||||
|
# Ensure :restart works with --temp-basedir
|
||||||
|
argdict['temp_basedir'] = False
|
||||||
|
argdict['temp_basedir_restarted'] = True
|
||||||
|
|
||||||
# Dump the data
|
# Dump the data
|
||||||
data = json.dumps(argdict)
|
data = json.dumps(argdict)
|
||||||
args += ['--json-args', data]
|
args += ['--json-args', data]
|
||||||
@ -572,7 +576,7 @@ class Quitter:
|
|||||||
raise cmdexc.CommandError("SyntaxError in {}:{}: {}".format(
|
raise cmdexc.CommandError("SyntaxError in {}:{}: {}".format(
|
||||||
e.filename, e.lineno, e))
|
e.filename, e.lineno, e))
|
||||||
if ok:
|
if ok:
|
||||||
self.shutdown()
|
self.shutdown(restart=True)
|
||||||
|
|
||||||
def restart(self, pages=(), session=None):
|
def restart(self, pages=(), session=None):
|
||||||
"""Inner logic to restart qutebrowser.
|
"""Inner logic to restart qutebrowser.
|
||||||
@ -615,7 +619,8 @@ class Quitter:
|
|||||||
|
|
||||||
@cmdutils.register(instance='quitter', name=['quit', 'q'],
|
@cmdutils.register(instance='quitter', name=['quit', 'q'],
|
||||||
ignore_args=True)
|
ignore_args=True)
|
||||||
def shutdown(self, status=0, session=None, last_window=False):
|
def shutdown(self, status=0, session=None, last_window=False,
|
||||||
|
restart=False):
|
||||||
"""Quit qutebrowser.
|
"""Quit qutebrowser.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -623,6 +628,7 @@ class Quitter:
|
|||||||
session: A session name if saving should be forced.
|
session: A session name if saving should be forced.
|
||||||
last_window: If the shutdown was triggered due to the last window
|
last_window: If the shutdown was triggered due to the last window
|
||||||
closing.
|
closing.
|
||||||
|
restart: If we're planning to restart.
|
||||||
"""
|
"""
|
||||||
if self._shutting_down:
|
if self._shutting_down:
|
||||||
return
|
return
|
||||||
@ -652,13 +658,14 @@ class Quitter:
|
|||||||
# in the real main event loop, or we'll get a segfault.
|
# in the real main event loop, or we'll get a segfault.
|
||||||
log.destroy.debug("Deferring real shutdown because question was "
|
log.destroy.debug("Deferring real shutdown because question was "
|
||||||
"active.")
|
"active.")
|
||||||
QTimer.singleShot(0, functools.partial(self._shutdown, status))
|
QTimer.singleShot(0, functools.partial(self._shutdown, status,
|
||||||
|
restart=restart))
|
||||||
else:
|
else:
|
||||||
# If we have no questions to shut down, we are already in the real
|
# If we have no questions to shut down, we are already in the real
|
||||||
# event loop, so we can shut down immediately.
|
# event loop, so we can shut down immediately.
|
||||||
self._shutdown(status)
|
self._shutdown(status, restart=restart)
|
||||||
|
|
||||||
def _shutdown(self, status):
|
def _shutdown(self, status, restart):
|
||||||
"""Second stage of shutdown."""
|
"""Second stage of shutdown."""
|
||||||
log.destroy.debug("Stage 2 of shutting down...")
|
log.destroy.debug("Stage 2 of shutting down...")
|
||||||
if qApp is None:
|
if qApp is None:
|
||||||
@ -699,7 +706,8 @@ class Quitter:
|
|||||||
log.destroy.debug("Deactivating crash log...")
|
log.destroy.debug("Deactivating crash log...")
|
||||||
objreg.get('crash-handler').destroy_crashlogfile()
|
objreg.get('crash-handler').destroy_crashlogfile()
|
||||||
# Delete temp basedir
|
# Delete temp basedir
|
||||||
if self._args.temp_basedir:
|
if ((self._args.temp_basedir or self._args.temp_basedir_restarted) and
|
||||||
|
not restart):
|
||||||
atexit.register(shutil.rmtree, self._args.basedir,
|
atexit.register(shutil.rmtree, self._args.basedir,
|
||||||
ignore_errors=True)
|
ignore_errors=True)
|
||||||
# If we don't kill our custom handler here we might get segfaults
|
# If we don't kill our custom handler here we might get segfaults
|
||||||
|
@ -70,6 +70,7 @@ def get_argparser():
|
|||||||
help="How URLs should be opened if there is already a "
|
help="How URLs should be opened if there is already a "
|
||||||
"qutebrowser instance running.")
|
"qutebrowser instance running.")
|
||||||
parser.add_argument('--json-args', help=argparse.SUPPRESS)
|
parser.add_argument('--json-args', help=argparse.SUPPRESS)
|
||||||
|
parser.add_argument('--temp-basedir-restarted', help=argparse.SUPPRESS)
|
||||||
|
|
||||||
debug = parser.add_argument_group('debug arguments')
|
debug = parser.add_argument_group('debug arguments')
|
||||||
debug.add_argument('-l', '--loglevel', dest='loglevel',
|
debug.add_argument('-l', '--loglevel', dest='loglevel',
|
||||||
|
Loading…
Reference in New Issue
Block a user