mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #10254 from druiz17/tablet-crash
Potential fix for crash for TabletScriptingInterface::getTabletWindow
This commit is contained in:
commit
aea8b020d2
4 changed files with 23 additions and 3 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,15 @@
|
|||
#include <InfoView.h>
|
||||
#include "SoundEffect.h"
|
||||
|
||||
|
||||
QScriptValue tabletToScriptValue(QScriptEngine* engine, TabletProxy* const &in) {
|
||||
return engine->newQObject(in, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects);
|
||||
}
|
||||
|
||||
void tabletFromScriptValue(const QScriptValue& value, TabletProxy* &out) {
|
||||
out = qobject_cast<TabletProxy*>(value.toQObject());
|
||||
}
|
||||
|
||||
TabletScriptingInterface::TabletScriptingInterface() {
|
||||
qmlRegisterType<SoundEffect>("Hifi", 1, 0, "SoundEffect");
|
||||
}
|
||||
|
@ -41,7 +50,7 @@ QObject* TabletScriptingInterface::getSystemToolbarProxy() {
|
|||
}
|
||||
}
|
||||
|
||||
QObject* TabletScriptingInterface::getTablet(const QString& tabletId) {
|
||||
TabletProxy* TabletScriptingInterface::getTablet(const QString& tabletId) {
|
||||
|
||||
std::lock_guard<std::mutex> guard(_mutex);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -96,6 +96,9 @@ void OffscreenUi::create(QOpenGLContext* context) {
|
|||
rootContext->setContextProperty("OffscreenUi", this);
|
||||
rootContext->setContextProperty("offscreenFlags", offscreenFlags = new OffscreenFlags());
|
||||
rootContext->setContextProperty("fileDialogHelper", new FileDialogHelper());
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
TabletProxy* tablet = tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system");
|
||||
rootContext->engine()->setObjectOwnership(tablet, QQmlEngine::CppOwnership);
|
||||
}
|
||||
|
||||
void OffscreenUi::show(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f) {
|
||||
|
|
Loading…
Reference in a new issue