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
8181 }
8282
8383 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−
9284 auto offscreenUi = DependencyManager::get<OffscreenUi>();
9385 auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping);
9486 if (!result.isValid()) {
9587 return;
9688 }
89+ mapping = result.toString();
9790
9891 // Check for override
99− if (isKnownMapping(result.toString())) {
92+ if (isKnownMapping(mapping)) {
10093 auto message = "The following file already exists:\n" + path + "\nDo you want to override it?";
10194 auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "", message,
10295 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
@@ -105,7 +98,7 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, · 2 unmodified lines
10598 }
10699 }
107100
108− auto upload = DependencyManager::get<AssetClient>()->createUpload(file.readAll());
101+ auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
109102 QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
110103 if (upload->getError() != AssetUpload::NoError) {
111104 if (callback.isCallable()) {
@@ -242,7 +235,7 @@ void AssetMappingModel::refresh() { · 130 unmodified lines
242235 auto it = existingPaths.begin();
243236 while (it != existingPaths.end()) {
244237 auto item = _pathToItemMap[*it];
245− if (item->data(Qt::UserRole + 1).toBool()) {
238+ if (item && item->data(Qt::UserRole + 1).toBool()) {
246239 it = existingPaths.erase(it);
247240 } else {
248241 ++it;