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 Dec 24, 2024
1 parent 5d3b1c2 commit eb03f7b
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,37 +119,39 @@ 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()
}
}

function createDialog(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 eb03f7b

Please sign in to comment.