use InvokeMethod so that texture change happens on the right thread

This commit is contained in:
Stephen Birarda 2014-10-22 12:07:00 -07:00
parent e079ec4363
commit e97aef581a
2 changed files with 6 additions and 2 deletions

View file

@ -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:

View file

@ -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));
}
}