diff --git a/plugin/src/Caelestia/cutils.cpp b/plugin/src/Caelestia/cutils.cpp index 6e3bfa99..b6ec33a8 100644 --- a/plugin/src/Caelestia/cutils.cpp +++ b/plugin/src/Caelestia/cutils.cpp @@ -75,13 +75,20 @@ void CUtils::saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, Q QObject::connect(watcher, &QFutureWatcher::finished, this, [=]() { if (watcher->result()) { if (onSaved.isCallable()) { - onSaved.call( - { QJSValue(path.toLocalFile()), engine->toScriptValue(QVariant::fromValue(path)) }); + QJSValueList args = { QJSValue(path.toLocalFile()) }; + if (engine) { + args << engine->toScriptValue(QVariant::fromValue(path)); + } + onSaved.call(args); } } else { qWarning() << "CUtils::saveItem: failed to save" << path; if (onFailed.isCallable()) { - onFailed.call({ engine->toScriptValue(QVariant::fromValue(path)) }); + if (engine) { + onFailed.call({ engine->toScriptValue(QVariant::fromValue(path)) }); + } else { + onFailed.call(); + } } } watcher->deleteLater();