fix: fix empty string in gpus_in_use settings to select the correct variant

This commit is contained in:
Louis 2024-11-21 14:09:14 +07:00
parent fe6412e1d4
commit 55ad2f3931
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
2 changed files with 9 additions and 4 deletions

View File

@ -53,7 +53,7 @@ export const useSettings = () => {
const settings = await readSettings()
if (runMode != null) settings.run_mode = runMode
if (notify != null) settings.notify = notify
if (gpusInUse != null) settings.gpus_in_use = gpusInUse
if (gpusInUse != null) settings.gpus_in_use = gpusInUse.filter((e) => !!e)
if (vulkan != null) {
settings.vulkan = vulkan
// GPU enabled, set run_mode to 'gpu'

View File

@ -207,7 +207,12 @@ const Advanced = () => {
let updatedGpusInUse = [...gpusInUse]
if (updatedGpusInUse.includes(gpuId)) {
updatedGpusInUse = updatedGpusInUse.filter((id) => id !== gpuId)
if (gpuEnabled && updatedGpusInUse.length === 0) {
if (
gpuEnabled &&
updatedGpusInUse.length === 0 &&
gpuId &&
gpuId.trim()
) {
// Vulkan support only allow 1 active device at a time
if (vulkanEnabled) {
updatedGpusInUse = []
@ -219,10 +224,10 @@ const Advanced = () => {
if (vulkanEnabled) {
updatedGpusInUse = []
}
updatedGpusInUse.push(gpuId)
if (gpuId && gpuId.trim()) updatedGpusInUse.push(gpuId)
}
setGpusInUse(updatedGpusInUse)
await saveSettings({ gpusInUse: updatedGpusInUse })
await saveSettings({ gpusInUse: updatedGpusInUse.filter((e) => !!e) })
// Reload window to apply changes
// This will trigger engine servers to restart
window.location.reload()