Fix :restart when installed as Python egg with launcher

This commit is contained in:
Florian Bruhin 2014-09-25 07:07:27 +02:00
parent e029139764
commit 8421ff7ad0

View File

@ -608,7 +608,11 @@ class Application(QApplication):
log.destroy.debug("sys.path: {}".format(sys.path))
log.destroy.debug("sys.argv: {}".format(sys.argv))
log.destroy.debug("frozen: {}".format(hasattr(sys, 'frozen')))
if hasattr(sys, 'frozen'):
if os.path.basename(sys.argv[0]) == 'qutebrowser':
# Launched via launcher script
args = [sys.argv[0]]
cwd = None
elif hasattr(sys, 'frozen'):
args = [sys.executable]
cwd = os.path.abspath(os.path.dirname(sys.executable))
else:
@ -624,6 +628,9 @@ class Application(QApplication):
log.destroy.debug("args: {}".format(args))
log.destroy.debug("cwd: {}".format(cwd))
# Open a new process and immediately shutdown the existing one
if cwd is None:
subprocess.Popen(args)
else:
subprocess.Popen(args, cwd=cwd)
if shutdown:
self.shutdown()