From e97aef581a462dc4126372c000706a4b3bbe61fc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Oct 2014 12:07:00 -0700 Subject: [PATCH] use InvokeMethod so that texture change happens on the right thread --- interface/src/renderer/Model.h | 2 +- interface/src/ui/overlays/ModelOverlay.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 3618d8103e..272844ac4a 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -183,7 +183,7 @@ public: void inverseKinematics(int jointIndex, glm::vec3 position, const glm::quat& rotation, float priority); - void setTextureWithNameToURL(const QString& name, const QUrl& url) + Q_INVOKABLE void setTextureWithNameToURL(const QString& name, const QUrl& url) { _geometry->setTextureWithNameToURL(name, url); } protected: diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index ac3d7b8a2b..0169bf40cd 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -107,9 +107,13 @@ void ModelOverlay::setProperties(const QScriptValue &properties) { if (texturesValue.isValid()) { QVariantMap textureMap = texturesValue.toVariant().toMap(); foreach(const QString& key, textureMap.keys()) { + QUrl newTextureURL = textureMap[key].toUrl(); qDebug() << "Updating texture named" << key << "to texture at URL" << newTextureURL; - _model.setTextureWithNameToURL(key, newTextureURL); + + QMetaObject::invokeMethod(&_model, "setTextureWithNameToURL", Qt::AutoConnection, + Q_ARG(const QString&, key), + Q_ARG(const QUrl&, newTextureURL)); } }