Couple bug fixes

This commit is contained in:
Atlante45 2016-03-10 14:04:52 -08:00
parent 7d7a683b18
commit 548d826a4e
5 changed files with 10 additions and 16 deletions

View file

@ -217,7 +217,7 @@ Window {
var addToWorld = addToWorldCheckBox.checked
var path = assetProxyModel.data(treeView.currentIndex, 0x100);
var directory = path ? path.slice(0, path.lastIndexOf('/') + 1) : "";
var directory = path ? path.slice(0, path.lastIndexOf('/') + 1) : "/";
var filename = fileUrl.slice(fileUrl.lastIndexOf('/') + 1);
Assets.uploadFile(fileUrl, directory + filename, function(err) {
@ -227,6 +227,8 @@ Window {
} else {
console.log("Finished uploading: ", fileUrl);
}
reload();
});
}

View file

@ -426,7 +426,6 @@ bool setupEssentials(int& argc, char** argv) {
DependencyManager::set<MessagesClient>();
DependencyManager::set<UserInputMapper>();
DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
DependencyManager::set<AssetMappingsScriptingInterface>();
DependencyManager::set<InterfaceParentFinder>();
DependencyManager::set<EntityTreeRenderer>(true, qApp, qApp);
DependencyManager::set<CompositorHelper>();
@ -1296,7 +1295,7 @@ void Application::initializeUi() {
rootContext->setContextProperty("Quat", new Quat());
rootContext->setContextProperty("Vec3", new Vec3());
rootContext->setContextProperty("Uuid", new ScriptUUID());
rootContext->setContextProperty("Assets", DependencyManager::get<AssetMappingsScriptingInterface>().data());
rootContext->setContextProperty("Assets", new AssetMappingsScriptingInterface());
rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());

View file

@ -81,22 +81,15 @@ void AssetMappingsScriptingInterface::getMapping(QString path, QJSValue callback
}
void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, QJSValue callback) {
QFile file(path);
if (!file.open(QFile::ReadOnly)) {
qCWarning(asset_client) << "Error uploading file to asset server:\n"
<< "Could not open" << qPrintable(path);
OffscreenUi::warning("File Error", "Could not open file: " + path, QMessageBox::Ok);
return;
}
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping);
if (!result.isValid()) {
return;
}
mapping = result.toString();
// Check for override
if (isKnownMapping(result.toString())) {
if (isKnownMapping(mapping)) {
auto message = "The following file already exists:\n" + path + "\nDo you want to override it?";
auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "", message,
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
@ -105,7 +98,7 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping,
}
}
auto upload = DependencyManager::get<AssetClient>()->createUpload(file.readAll());
auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
if (upload->getError() != AssetUpload::NoError) {
if (callback.isCallable()) {
@ -242,7 +235,7 @@ void AssetMappingModel::refresh() {
auto it = existingPaths.begin();
while (it != existingPaths.end()) {
auto item = _pathToItemMap[*it];
if (item->data(Qt::UserRole + 1).toBool()) {
if (item && item->data(Qt::UserRole + 1).toBool()) {
it = existingPaths.erase(it);
} else {
++it;

View file

@ -45,7 +45,7 @@
};
class AssetMappingsScriptingInterface : public QObject, public Dependency {
class AssetMappingsScriptingInterface : public QObject {
Q_OBJECT
Q_PROPERTY(AssetMappingModel* mappingModel READ getAssetMappingModel CONSTANT)
Q_PROPERTY(QAbstractProxyModel* proxyModel READ getProxyModel CONSTANT)

View file

@ -109,7 +109,7 @@ void SetMappingRequest::doStart() {
auto validPath = isValidPath(_path);
auto validHash = isValidHash(_hash);
if (!validPath || !validHash) {
_error = validPath ? MappingRequest::InvalidPath : MappingRequest::InvalidHash;
_error = !validPath ? MappingRequest::InvalidPath : MappingRequest::InvalidHash;
emit finished(this);
return;
}