Repository navigation
Don't open the running VMs question twice - #148
Conversation
The tray's Quit opened a second copy of the "VMs are still running" question on top of the one already up, and answering both ran shutDownAllAndQuit twice: two balloons, two power button presses per guest and two Force off questions. The still working question from #139 already had a flag for this; give the running VMs question the same one, and leave it up when the window is closed while it is open.
With the guard in place, Quit from the tray did nothing at all while a question was open, and if the window had been minimized the question was out of sight. Show the window instead so the click points at the question that is waiting for an answer.
A21-devs
left a comment
There was a problem hiding this comment.
The flag itself matches askingAboutWork and does fix the double question. Two things around it that I think are real, both about the window close handler rather than the new flag:
| @@ -81,8 +83,8 @@ function createWindow(): void { | |||
| if (quitting || !backend) return | |||
| if (backend.runner.runningNames().length === 0 && !hasWork()) return | |||
There was a problem hiding this comment.
This early return runs before the new question checks below, so it decides on state that can have changed while the question was up. If the last guest powers itself off while "VMs are still running" is open (the question is asked about VMs that are running, and a guest shutting down from its own menu is normal), runningNames() is empty and hasWork() is false, so the X closes the window with the message box still attached to it, and window-all-closed quits the app. Moving the askingAboutWork || askingAboutVms check above this line keeps the window alive until the question is answered, which is what the rest of the handler now assumes.
| // the still working question is up on this window, it gets answered there | ||
| if (askingAboutWork) return | ||
| // a question is already up on this window, it gets answered there | ||
| if (askingAboutWork || askingAboutVms) return |
There was a problem hiding this comment.
The Force off question in shutDownAllAndQuit (line 394) isn't covered by either flag. While it's open shuttingDown is true, so the X falls through to win.hide() two lines down and hides the window the question is attached to; the answer is then needed before the app does anything else, with nothing on screen to answer. Setting askingAboutVms around that dialog too would give it the same "leave it up" treatment this PR gives the other one.
|
Both findings were real, fixed in 6d14b6d:
Checked again after the fix: One unrelated thing from the test runs: |
Two gaps from reviewing this change: - the close handler decided on runningNames() and hasWork() before it looked at the open question, so a guest powering itself off while the question was up let the X close the window with the message box on it, and window-all-closed then quit the app - the Force off question at the end of shutDownAllAndQuit had no flag of its own, so closing the window hid the window it was attached to
A21-devs
left a comment
There was a problem hiding this comment.
Second pass over 6d14b6d. Both findings are really fixed: the close handler now checks the open question first and calls preventDefault() on that path, so the "all guests gone" early return can no longer close the window under a message box, and the Force off question sets the flag for as long as it is up, so the handler leaves it alone instead of hiding its window. One nit about what the flag now means.
| // the still working question is open. Quit and close don't open a second one meanwhile | ||
| let askingAboutWork = false | ||
| // the running VMs question is open. Same rule: no second copy from the tray or the window | ||
| let askingAboutVms = false |
There was a problem hiding this comment.
Nit: the flag now covers two questions, this one and the Force off question in shutDownAllAndQuit, so the comment reads a bit narrow. The second one also behaves slightly differently from what requestQuit promises: shuttingDown is true by then, so Quit from the tray returns on the line above instead of showing the window with the question on it. Not worth another flag, but the comment could say the flag means "a question about running VMs is open".
|
Took the nit: the flag's comment now says it covers both questions about running VMs. No behaviour change, typecheck still clean. |
Closes #144
The tray's Quit could open a second copy of the "VMs are still running" question on top of the one already up. Answering both ran
shutDownAllAndQuittwice, so every guest got the power button twice and two Force off questions could appear.What changed:
askingAboutVmsflag around the question, the same shape asaskingAboutWorkfrom Ask before quitting while a profile save or disk work runs #139.askAndQuitreturns early while it is set,requestQuitdoesn't start a new flow, and the window's close handler leaves the question up instead of hiding to the tray.showWindow()instead of doing nothing, so the click points at the question waiting for an answer (it was a silent no-op before, and worse if the window was minimized).Testing
npm run typecheck,npm test(153 pass),npm run buildnpm run smoke(hidden Electron run): SMOKE OK