Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Keep the installing flag across a dependency re-check

LNPANDYab6b915a4121
diff --git a/frontend-qt/nspb_qt/model.py b/frontend-qt/nspb_qt/model.py
index decb47e7..07963624 100644
--- a/frontend-qt/nspb_qt/model.py
+++ b/frontend-qt/nspb_qt/model.py
@@ -240,6 +240,18 @@ class Model(QObject):
deps.append(Dep('tool:' + tool, key, key + '.hint',
DepState.OK if found else DepState.MISSING, found or ''))
+ # Carry the in-flight flag across the rebuild. `check_deps` runs on a timer, at the end of
+ # every install, and whenever the user presses "Check again" — and each of those replaces
+ # every Dep object. Without this, a row being installed came back as a fresh `installing
+ # = False` row, so the panel showed an Install button for a download that was still
+ # running and pressing it started a second one (the report: "I installed LLVM and the SDK
+ # several times"). Two downloads into one folder is also how a half-unpacked toolchain
+ # appears on disk.
+ running = {d.id for d in self.deps if d.installing}
+ for d in deps:
+ if d.id in running:
+ d.installing = True
+
self.deps = deps
self.python_path, self.python_ok, self.python_ver = py, py_ok, py_ver
if not pu.IS_WIN:
@@ -540,6 +552,13 @@ class Model(QObject):
"""
if not dep.install:
return
+ if dep.installing:
+ # A second click while this row is already downloading. The button is disabled while
+ # it runs, but a rebuild of the panel (check_deps) used to hand out a fresh row, and
+ # two writers into one staging folder produce a broken toolchain.
+ self.log(self.t('dep.install.begin', dep.id) + ' — ' +
+ self.t('dep.installing') + '\n')
+ return
if dep.install[0].startswith('__win__:'):
self._install_win(dep, dep.install[0].split(':', 1)[1])
return