Clean up :later timers correctly on exceptions.
This commit is contained in:
parent
50f7067d6c
commit
7956f2b8e2
@ -37,22 +37,26 @@ def later(ms: int, *command, win_id):
|
||||
ms: How many milliseconds to wait.
|
||||
*command: The command to run, with optional args.
|
||||
"""
|
||||
app = objreg.get('app')
|
||||
timer = usertypes.Timer(name='later', parent=app)
|
||||
timer.setSingleShot(True)
|
||||
if ms < 0:
|
||||
raise cmdexc.CommandError("I can't run something in the past!")
|
||||
try:
|
||||
timer.setInterval(ms)
|
||||
except OverflowError:
|
||||
raise cmdexc.CommandError("Numeric argument is too large for internal "
|
||||
"int representation.")
|
||||
cmdline = ' '.join(command)
|
||||
commandrunner = runners.CommandRunner(win_id)
|
||||
timer.timeout.connect(
|
||||
functools.partial(commandrunner.run_safely, cmdline))
|
||||
timer.timeout.connect(timer.deleteLater)
|
||||
timer.start()
|
||||
app = objreg.get('app')
|
||||
timer = usertypes.Timer(name='later', parent=app)
|
||||
try:
|
||||
timer.setSingleShot(True)
|
||||
try:
|
||||
timer.setInterval(ms)
|
||||
except OverflowError:
|
||||
raise cmdexc.CommandError("Numeric argument is too large for "
|
||||
"internal int representation.")
|
||||
timer.timeout.connect(
|
||||
functools.partial(commandrunner.run_safely, cmdline))
|
||||
timer.timeout.connect(timer.deleteLater)
|
||||
timer.start()
|
||||
except: # pylint: disable=bare-except
|
||||
timer.deleteLater()
|
||||
raise
|
||||
|
||||
|
||||
@cmdutils.register(scope='window')
|
||||
|
Loading…
Reference in New Issue
Block a user