Fix :spawn -u -o

Fixes #6407
This commit is contained in:
Florian Bruhin 2021-04-23 10:42:34 +02:00
parent b1265cbeff
commit c7b3559d82
3 changed files with 14 additions and 5 deletions

View File

@ -1099,8 +1099,7 @@ class CommandDispatcher:
try:
runner = self._run_userscript(
s, cmd, args, verbose, output_messages, count)
runner.finished.connect(functools.partial(
_on_proc_finished, runner.proc))
runner.finished.connect(_on_proc_finished)
except cmdutils.CommandError as e:
message.error(str(e))

View File

@ -108,10 +108,11 @@ class _BaseUserscriptRunner(QObject):
Signals:
got_cmd: Emitted when a new command arrived and should be executed.
finished: Emitted when the userscript finished running.
arg: The finished GUIProcess object.
"""
got_cmd = pyqtSignal(str)
finished = pyqtSignal()
finished = pyqtSignal(guiprocess.GUIProcess)
def __init__(self, parent=None):
super().__init__(parent)
@ -288,8 +289,10 @@ class _POSIXUserscriptRunner(_BaseUserscriptRunner):
self._reader.cleanup()
self._reader.deleteLater()
self._reader = None
proc = self.proc
super()._cleanup()
self.finished.emit()
self.finished.emit(proc)
class _WindowsUserscriptRunner(_BaseUserscriptRunner):
@ -321,8 +324,9 @@ class _WindowsUserscriptRunner(_BaseUserscriptRunner):
log.misc.error("Invalid unicode in userscript output: {}"
.format(e))
proc = self.proc
super()._cleanup()
self.finished.emit()
self.finished.emit(proc)
@pyqtSlot()
def on_proc_error(self):

View File

@ -44,8 +44,14 @@ Feature: :spawn
When I run :spawn -u -m (echo-exe) Message 2
Then the message "Message 2" should be shown
Scenario: Running :spawn with -u -o
When I run :spawn -u -o (echo-exe) Message 3
And I wait for "load status for * url='qute://process/*'>: LoadStatus.success" in the log
Then the page should contain the plaintext "Message 3"
@posix
Scenario: Running :spawn with userscript
Given I clean up open tabs
When I open data/hello.txt
And I run :spawn -u (testdata)/userscripts/open_current_url
And I wait until data/hello.txt is loaded