mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:35:08 +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)));
|
||||
|
||||
registerGlobalObject("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
qScriptRegisterMetaType(this, tabletToScriptValue, tabletFromScriptValue);
|
||||
registerGlobalObject("Assets", &_assetScriptingInterface);
|
||||
registerGlobalObject("Resources", DependencyManager::get<ResourceScriptingInterface>().data());
|
||||
|
||||
|
|
|
@ -21,6 +21,17 @@
|
|||
#include <InfoView.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() {
|
||||
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);
|
||||
|
||||
|
@ -81,11 +92,6 @@ void TabletScriptingInterface::setQmlTabletRoot(QString tabletId, QQuickItem* qm
|
|||
|
||||
QQuickWindow* TabletScriptingInterface::getTabletWindow() {
|
||||
TabletProxy* tablet = qobject_cast<TabletProxy*>(getTablet("com.highfidelity.interface.tablet.system"));
|
||||
|
||||
if (!tablet) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QObject* qmlSurface = tablet->getTabletSurface();
|
||||
OffscreenQmlSurface* surface = dynamic_cast<OffscreenQmlSurface*>(qmlSurface);
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QScriptValue>
|
||||
#include <QtScript/QScriptValue>
|
||||
#include <QScriptEngine>
|
||||
#include <QScriptValueIterator>
|
||||
#include <QQuickItem>
|
||||
#include <QUuid>
|
||||
|
||||
|
@ -45,7 +47,7 @@ public:
|
|||
* @param name {String} tablet name
|
||||
* @return {TabletProxy} tablet instance
|
||||
*/
|
||||
Q_INVOKABLE QObject* getTablet(const QString& tabletId);
|
||||
Q_INVOKABLE TabletProxy* getTablet(const QString& tabletId);
|
||||
|
||||
void setToolbarMode(bool toolbarMode);
|
||||
|
||||
|
@ -259,6 +261,11 @@ protected:
|
|||
bool _landscape { false };
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(TabletProxy*);
|
||||
|
||||
QScriptValue tabletToScriptValue(QScriptEngine* engine, TabletProxy* const &in);
|
||||
void tabletFromScriptValue(const QScriptValue& value, TabletProxy* &out);
|
||||
|
||||
/**jsdoc
|
||||
* @class TabletButtonProxy
|
||||
* @property uuid {QUuid} READ_ONLY: uniquely identifies this button
|
||||
|
|
Loading…
Reference in a new issue