gtk: Run the application in the done() function handler

I still build the arguments to the application in the main do_command()
handler, but delay running it so the database won't be locked allowing
other commands to still work.

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
This commit is contained in:
Anna Schumaker 2023-11-07 15:50:29 -05:00
parent 2e85870c87
commit 79fae64f37
1 changed files with 6 additions and 4 deletions

View File

@ -100,17 +100,19 @@ class Command(commands.Command):
def do_command(self, args: argparse.Namespace) -> None: def do_command(self, args: argparse.Namespace) -> None:
"""Run the Gtk UI.""" """Run the Gtk UI."""
app_args = [] args.app_args = []
if args.runid is not None: if args.runid is not None:
if self.sql("SELECT 1 FROM xfstests_runs WHERE runid=?", if self.sql("SELECT 1 FROM xfstests_runs WHERE runid=?",
args.runid).fetchone(): args.runid).fetchone():
app_args.append(f"runid={args.runid}") args.app_args.append(f"runid={args.runid}")
else: else:
print(f"error: run #{args.runid} does not exist", print(f"error: run #{args.runid} does not exist",
file=sys.stderr) file=sys.stderr)
sys.exit(errno.ENOENT) sys.exit(errno.ENOENT)
else: else:
app_args.append("show-sidebar") args.app_args.append("show-sidebar")
Application(self.sql).run(app_args) def do_done(self, args: argparse.Namespace) -> None:
"""Run the application outside of a transaction."""
Application(self.sql).run(args.app_args)