Skip to content

Commit

Permalink
Fixed first time parse error bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Fefedu973 authored Jun 2, 2024
1 parent 2b5b5cc commit 81abfa8
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions OpenRGBBridge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ Item {
Component.onCompleted: {
useCustomPort.checked = service.getSetting("General", "UseCustomPort") === "true"
customPortContainer.active = useCustomPort.checked
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices")) || []
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}

if (useCustomPort.checked)
{
customPortContainer.item.children[0].text = service.getSetting("General", "CustomPort") || "9730"
Expand Down Expand Up @@ -322,7 +327,12 @@ Row {
let res = JSON.parse(xhr.responseText)
deviceList = res
deviceRepeater.model = deviceList
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices")) || []
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}

if (selectedDevices.length > 0)
{
for (var i = 0; i < deviceRepeater.count; i++) {
Expand Down Expand Up @@ -351,7 +361,12 @@ Row {
let res = JSON.parse(xhr.responseText)
deviceList = res
deviceRepeater.model = deviceList
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices")) || []
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}

if (selectedDevices.length > 0)
{
for (var i = 0; i < deviceRepeater.count; i++) {
Expand Down Expand Up @@ -462,7 +477,12 @@ Column {
}
}
onClicked: {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices")) || []
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}

if (selectedDevices.length == 0)
{
selectedDevices.push(modelData)
Expand Down

0 comments on commit 81abfa8

Please sign in to comment.