History

Couple bug fixes

Atlante45 committed 10 years ago

Commit 548d8261 parent 7d7a6835 files · +10 −16Browse files

Showing the changes to interface/src/scripting/AssetMappingsScriptingInterface.cpp (1 of 5 files). Show all

Unified · Split

interface/src/scripting/AssetMappingsScriptingInterface.cpp+4−11
@@ -81,22 +81,15 @@ void AssetMappingsScriptingInterface::getMapping(QString path, QJSValue callback · 80 unmodified lines
81}81}
82 82
83void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, QJSValue callback) {83void 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 auto offscreenUi = DependencyManager::get<OffscreenUi>();84 auto offscreenUi = DependencyManager::get<OffscreenUi>();
93 auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping);85 auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping);
94 if (!result.isValid()) {86 if (!result.isValid()) {
95 return;87 return;
96 }88 }
89 mapping = result.toString();
97 90
98 // Check for override91 // Check for override
99 if (isKnownMapping(result.toString())) {92 if (isKnownMapping(mapping)) {
100 auto message = "The following file already exists:\n" + path + "\nDo you want to override it?";93 auto message = "The following file already exists:\n" + path + "\nDo you want to override it?";
101 auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "", message,94 auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "", message,
102 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);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 QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {102 QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
110 if (upload->getError() != AssetUpload::NoError) {103 if (upload->getError() != AssetUpload::NoError) {
111 if (callback.isCallable()) {104 if (callback.isCallable()) {
@@ -242,7 +235,7 @@ void AssetMappingModel::refresh() { · 130 unmodified lines
242 auto it = existingPaths.begin();235 auto it = existingPaths.begin();
243 while (it != existingPaths.end()) {236 while (it != existingPaths.end()) {
244 auto item = _pathToItemMap[*it];237 auto item = _pathToItemMap[*it];
245 if (item->data(Qt::UserRole + 1).toBool()) {238 if (item && item->data(Qt::UserRole + 1).toBool()) {
246 it = existingPaths.erase(it);239 it = existingPaths.erase(it);
247 } else {240 } else {
248 ++it;241 ++it;