userscripts: Don't store a list of runners.

This commit is contained in:
Florian Bruhin 2014-09-29 20:16:54 +02:00
parent 865389bb34
commit 106ad9f4ed

View File

@ -17,11 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Functions to execute an userscript.
Module attributes:
_runners: Active userscript runners from run_userscript.
"""
"""Functions to execute an userscript."""
import os
import os.path
@ -36,10 +32,6 @@ from qutebrowser.utils import message, log, utils
from qutebrowser.commands import runners, cmdexc
_runners = []
_commandrunners = []
class _BlockingFIFOReader(QObject):
"""A worker which reads commands from a FIFO endlessly.
@ -333,15 +325,14 @@ else:
def run(cmd, *args, url, win_id):
"""Convenience method to run an userscript."""
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
# We don't remove the password in the URL here, as it's probably safe to
# pass via env variable..
urlstr = url.toString(QUrl.FullyEncoded)
commandrunner = runners.CommandRunner(win_id)
runner = UserscriptRunner(win_id)
commandrunner = runners.CommandRunner(win_id, tabbed_browser)
runner = UserscriptRunner(win_id, tabbed_browser)
runner.got_cmd.connect(commandrunner.run_safely)
runner.run(cmd, *args, env={'QUTE_URL': urlstr})
_runners.append(runner)
_commandrunners.append(commandrunner)
runner.finished.connect(functools.partial(_runners.remove, runner))
runner.finished.connect(
functools.partial(_commandrunners.remove, commandrunner))
runner.finished.connect(commandrunner.deleteLater)
runner.finished.connect(runner.deleteLater)