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