Showing the changes to interface/src/scripting/AssetMappingsScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -81,22 +81,15 @@ void AssetMappingsScriptingInterface::getMapping(QString path, QJSValue callback · 80 unmodified lines | ||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, QJSValue callback) { |
| 84 | − QFile file(path); | |
| 85 | − if (!file.open(QFile::ReadOnly)) { | |
| 86 | − qCWarning(asset_client) << "Error uploading file to asset server:\n" | |
| 87 | − << "Could not open" << qPrintable(path); | |
| 88 | − OffscreenUi::warning("File Error", "Could not open file: " + path, QMessageBox::Ok); | |
| 89 | − return; | |
| 90 | − } | |
| 91 | − | |
| 92 | 84 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 93 | 85 | auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping); |
| 94 | 86 | if (!result.isValid()) { |
| 95 | 87 | return; |
| 96 | 88 | } |
| 89 | + mapping = result.toString(); | |
| 97 | 90 | |
| 98 | 91 | // Check for override |
| 99 | − if (isKnownMapping(result.toString())) { | |
| 92 | + if (isKnownMapping(mapping)) { | |
| 100 | 93 | auto message = "The following file already exists:\n" + path + "\nDo you want to override it?"; |
| 101 | 94 | auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "", message, |
| 102 | 95 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
| @@ -105,7 +98,7 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, · 2 unmodified lines | ||
| 105 | 98 | } |
| 106 | 99 | } |
| 107 | 100 | |
| 108 | − auto upload = DependencyManager::get<AssetClient>()->createUpload(file.readAll()); | |
| 101 | + auto upload = DependencyManager::get<AssetClient>()->createUpload(path); | |
| 109 | 102 | QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { |
| 110 | 103 | if (upload->getError() != AssetUpload::NoError) { |
| 111 | 104 | if (callback.isCallable()) { |
| @@ -242,7 +235,7 @@ void AssetMappingModel::refresh() { · 130 unmodified lines | ||
| 242 | 235 | auto it = existingPaths.begin(); |
| 243 | 236 | while (it != existingPaths.end()) { |
| 244 | 237 | auto item = _pathToItemMap[*it]; |
| 245 | − if (item->data(Qt::UserRole + 1).toBool()) { | |
| 238 | + if (item && item->data(Qt::UserRole + 1).toBool()) { | |
| 246 | 239 | it = existingPaths.erase(it); |
| 247 | 240 | } else { |
| 248 | 241 | ++it; |