From 652cd059c41cb1e1811fb6329484e561eeff38f1 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 19 Oct 2019 01:39:00 -0400 Subject: [PATCH] Prevent makeObject callback from running twice --- src/qml/utils.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qml/utils.js b/src/qml/utils.js index 5410d6fc..fe9cdd27 100644 --- a/src/qml/utils.js +++ b/src/qml/utils.js @@ -6,20 +6,21 @@ function makeObject(url, parent=null, properties={}, callback=null) { if ([Component.Null, Component.Error].includes(status)) { console.error("Failed creating component: ", comp.errorString()) - } else if (status == Component.Ready) { + } else if (! ready && status === Component.Ready) { let incu = comp.incubateObject(parent, properties, Qt.Asynchronous) - if (incu.status == Component.Ready) { + if (incu.status === Component.Ready) { if (callback) callback(incu.object) + ready = true return } incu.onStatusChanged = (istatus) => { - if (incu.status == Component.Error) { + if (incu.status === Component.Error) { console.error("Failed incubating object: ", incu.errorString()) - } else if (istatus == Component.Ready && callback && ! ready) { + } else if (istatus === Component.Ready && callback && ! ready) { if (callback) callback(incu.object) ready = true } @@ -27,7 +28,7 @@ function makeObject(url, parent=null, properties={}, callback=null) { } }) - if (comp.status == Component.Ready) comp.statusChanged(comp.status) + if (comp.status === Component.Ready) comp.statusChanged(comp.status) }