Skip to content

Commit

Permalink
More robust error handling in InteractiveProvider.qml
Browse files Browse the repository at this point in the history
When an error occurs while creating a component, don't cause even more errors by reading from `null` at `dialogObj.object.objectId`
  • Loading branch information
cbjeukendrup committed Oct 29, 2024
1 parent 9e1ba52 commit f245ae6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/framework/ui/qml/Muse/Ui/InteractiveProvider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ Item {

var dialogObj = root.createDialog(page.module, dialogPath, page.params)
data.setValue("ret", dialogObj.ret)
data.setValue("objectId", dialogObj.object.objectId)

if (dialogObj.ret.errcode > 0) {
return
}

data.setValue("objectId", dialogObj.object.objectId)

if (Boolean(data.value("sync")) && data.value("sync") === true) {
dialogObj.object.exec()
} else {
Expand Down Expand Up @@ -118,29 +119,31 @@ Item {
if (dialog.selectFolder) {
dialogObj = root.createDialog("", "internal/FolderDialog.qml", dialog.params)
} else {
dialogObj = root.createDialog("internal/FileDialog.qml", dialog.params)
dialogObj = root.createDialog("", "internal/FileDialog.qml", dialog.params)
}

data.setValue("ret", dialogObj.ret)
data.setValue("objectId", dialogObj.object.objectId)

if (dialogObj.ret.errcode > 0) {
return
}

data.setValue("objectId", dialogObj.object.objectId)

dialogObj.object.open()
}

function onFireOpenProgressDialog(data) {
var dialog = data.data()
var dialogObj = root.createDialog("", "internal/ProgressDialog.qml", dialog.params)
data.setValue("ret", dialogObj.ret)
data.setValue("objectId", dialogObj.object.objectId)

if (dialogObj.ret.errcode > 0) {
return
}

data.setValue("objectId", dialogObj.object.objectId)

dialogObj.object.open()
}
}
Expand All @@ -149,7 +152,7 @@ Item {
console.log(module, path, params)
var comp = module ? Qt.createComponent(module, path) : Qt.createComponent(path)
if (comp.status !== Component.Ready) {
console.log("[qml] failed create component: " + path + ", err: " + comp.errorString())
console.error("Could not create component: " + path + ", err: " + comp.errorString())
return { "ret": { "errcode": 102 } } // CreateFailed
}

Expand Down

0 comments on commit f245ae6

Please sign in to comment.