mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 16:02:58 +02:00
crash fix
This commit is contained in:
parent
b2a11aa9ab
commit
1ec4081a99
3 changed files with 22 additions and 8 deletions
|
@ -669,6 +669,7 @@ void ScriptEngine::init() {
|
||||||
globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
|
globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
|
||||||
|
|
||||||
registerGlobalObject("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
|
registerGlobalObject("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
|
||||||
|
qScriptRegisterMetaType(this, tabletToScriptValue, tabletFromScriptValue);
|
||||||
registerGlobalObject("Assets", &_assetScriptingInterface);
|
registerGlobalObject("Assets", &_assetScriptingInterface);
|
||||||
registerGlobalObject("Resources", DependencyManager::get<ResourceScriptingInterface>().data());
|
registerGlobalObject("Resources", DependencyManager::get<ResourceScriptingInterface>().data());
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,17 @@
|
||||||
#include <InfoView.h>
|
#include <InfoView.h>
|
||||||
#include "SoundEffect.h"
|
#include "SoundEffect.h"
|
||||||
|
|
||||||
|
|
||||||
|
QScriptValue tabletToScriptValue(QScriptEngine* engine, TabletProxy* const &in) {
|
||||||
|
qDebug() << "------------------- converting tabletProxy to scriptValue <--------------------";
|
||||||
|
return engine->newQObject(in, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tabletFromScriptValue(const QScriptValue& value, TabletProxy* &out) {
|
||||||
|
qDebug() << "----------------> value to tabletProxy <----------------";
|
||||||
|
out = qobject_cast<TabletProxy*>(value.toQObject());
|
||||||
|
}
|
||||||
|
|
||||||
TabletScriptingInterface::TabletScriptingInterface() {
|
TabletScriptingInterface::TabletScriptingInterface() {
|
||||||
qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");
|
qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");
|
||||||
}
|
}
|
||||||
|
@ -41,7 +52,7 @@ QObject* TabletScriptingInterface::getSystemToolbarProxy() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* TabletScriptingInterface::getTablet(const QString& tabletId) {
|
TabletProxy* TabletScriptingInterface::getTablet(const QString& tabletId) {
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(_mutex);
|
std::lock_guard<std::mutex> guard(_mutex);
|
||||||
|
|
||||||
|
@ -81,11 +92,6 @@ void TabletScriptingInterface::setQmlTabletRoot(QString tabletId, QQuickItem* qm
|
||||||
|
|
||||||
QQuickWindow* TabletScriptingInterface::getTabletWindow() {
|
QQuickWindow* TabletScriptingInterface::getTabletWindow() {
|
||||||
TabletProxy* tablet = qobject_cast<TabletProxy*>(getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = qobject_cast<TabletProxy*>(getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
|
|
||||||
if (!tablet) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject* qmlSurface = tablet->getTabletSurface();
|
QObject* qmlSurface = tablet->getTabletSurface();
|
||||||
OffscreenQmlSurface* surface = dynamic_cast<OffscreenQmlSurface*>(qmlSurface);
|
OffscreenQmlSurface* surface = dynamic_cast<OffscreenQmlSurface*>(qmlSurface);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QScriptValue>
|
#include <QtScript/QScriptValue>
|
||||||
|
#include <QScriptEngine>
|
||||||
|
#include <QScriptValueIterator>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
@ -45,7 +47,7 @@ public:
|
||||||
* @param name {String} tablet name
|
* @param name {String} tablet name
|
||||||
* @return {TabletProxy} tablet instance
|
* @return {TabletProxy} tablet instance
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE QObject* getTablet(const QString& tabletId);
|
Q_INVOKABLE TabletProxy* getTablet(const QString& tabletId);
|
||||||
|
|
||||||
void setToolbarMode(bool toolbarMode);
|
void setToolbarMode(bool toolbarMode);
|
||||||
|
|
||||||
|
@ -259,6 +261,11 @@ protected:
|
||||||
bool _landscape { false };
|
bool _landscape { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(TabletProxy*);
|
||||||
|
|
||||||
|
QScriptValue tabletToScriptValue(QScriptEngine* engine, TabletProxy* const &in);
|
||||||
|
void tabletFromScriptValue(const QScriptValue& value, TabletProxy* &out);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @class TabletButtonProxy
|
* @class TabletButtonProxy
|
||||||
* @property uuid {QUuid} READ_ONLY: uniquely identifies this button
|
* @property uuid {QUuid} READ_ONLY: uniquely identifies this button
|
||||||
|
|
Loading…
Reference in a new issue