Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -18,6 +18,10 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <recording/Frame.h> |
| 19 | 19 | #include <recording/ClipCache.h> |
| 20 | 20 | |
| 21 | + | |
| 22 | +#include <QtScript/QScriptValue> | |
| 23 | +#include <AssetClient.h> | |
| 24 | +#include <AssetUpload.h> | |
| 21 | 25 | #include <QtCore/QUrl> |
| 22 | 26 | #include <QtWidgets/QFileDialog> |
| 23 | 27 | |
| @@ -176,13 +180,18 @@ void RecordingScriptingInterface::saveRecording(const QString& filename) { · 152 unmodified lines | ||
| 176 | 180 | } |
| 177 | 181 | |
| 178 | 182 | bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUrl) { |
| 179 | − if (!getClipAtpUrl.isFunction()) | |
| 183 | + if (!getClipAtpUrl.isFunction()) { | |
| 184 | + qCWarning(scriptengine) << "The argument is not a function."; | |
| 180 | 185 | return false; |
| 186 | + } | |
| 187 | + | |
| 181 | 188 | |
| 182 | 189 | if (QThread::currentThread() != thread()) { |
| 190 | + bool result{ false }; | |
| 183 | 191 | QMetaObject::invokeMethod(this, "saveRecordingToAsset", Qt::BlockingQueuedConnection, |
| 184 | − Q_ARG(QScriptValue, getClipAtpUrl)); | |
| 185 | − return false; | |
| 192 | + Q_ARG(QScriptValue, getClipAtpUrl), | |
| 193 | + Q_RETURN_ARG(bool, result)); | |
| 194 | + return result; | |
| 186 | 195 | } |
| 187 | 196 | |
| 188 | 197 | if (!_lastClip) { |
| @@ -192,7 +201,6 @@ bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUr · 3 unmodified lines | ||
| 192 | 201 | |
| 193 | 202 | if (auto upload = DependencyManager::get<AssetClient>()->createUpload(recording::Clip::toBuffer(_lastClip), HFR_EXTENSION)) { |
| 194 | 203 | QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { |
| 195 | − auto filename = QFileInfo(upload->getFilename()).fileName(); | |
| 196 | 204 | QString clip_atp_url = ""; |
| 197 | 205 | |
| 198 | 206 | if (upload->getError() == AssetUpload::NoError) { |
| @@ -200,7 +208,7 @@ bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUr · 1 unmodified line | ||
| 200 | 208 | clip_atp_url = QString("%1:%2.%3").arg(URL_SCHEME_ATP, hash, upload->getExtension()); |
| 201 | 209 | upload->deleteLater(); |
| 202 | 210 | } else { |
| 203 | − qDebug() << "Error during the Asset upload."; | |
| 211 | + qCWarning(scriptengine) << "Error during the Asset upload."; | |
| 204 | 212 | } |
| 205 | 213 | |
| 206 | 214 | QScriptValueList args; |
| @@ -211,6 +219,7 @@ bool RecordingScriptingInterface::saveRecordingToAsset(QScriptValue getClipAtpUr · 4 unmodified lines | ||
| 211 | 219 | return true; |
| 212 | 220 | } |
| 213 | 221 | |
| 222 | + qCWarning(scriptengine) << "Saving on asset failed."; | |
| 214 | 223 | return false; |
| 215 | 224 | } |
| 216 | 225 | |