scripting: close the VM's window when updating its configuration

A VM's window is kept after it stops and run(vm:) reuses it as is. The Edit
button closes it before opening the settings, but AppleScript's update
configuration did not. If the displays were removed that way, the next start
got the old display window, which looks up the now missing display 0 and
crashes with an index out of range.

Close the window before updating the configuration, like the Edit button does,
so the next start creates the right kind of window.

Resolves #7882

Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
osy
2026-09-22 14:11:18 -05:00
parent 8bc7a0ba7e
commit adb43bffbb
+1
View File
@@ -34,6 +34,7 @@ import Foundation
guard vm.state == .stopped else {
throw ScriptingError.notStopped
}
data.close(vm: box) // close window
let wrapper = UTMScriptingConfigImpl(vm.config)
try wrapper.updateConfiguration(from: newConfiguration)
try await data.save(vm: box)