mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:57:13 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into yellow
This commit is contained in:
commit
bc0f719b71
11 changed files with 114 additions and 7 deletions
|
@ -15,9 +15,11 @@ macro(TARGET_WEBRTC)
|
||||||
# select_library_configurations(WEBRTC)
|
# select_library_configurations(WEBRTC)
|
||||||
else()
|
else()
|
||||||
set(WEBRTC_INCLUDE_DIRS "${VCPKG_INSTALL_ROOT}/include/webrtc")
|
set(WEBRTC_INCLUDE_DIRS "${VCPKG_INSTALL_ROOT}/include/webrtc")
|
||||||
find_library(WEBRTC_LIBRARY NAMES webrtc PATHS ${VCPKG_INSTALL_ROOT}/lib/ NO_DEFAULT_PATH)
|
|
||||||
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${WEBRTC_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${WEBRTC_INCLUDE_DIRS})
|
||||||
target_link_libraries(${TARGET_NAME} ${WEBRTC_LIBRARY})
|
find_library(WEBRTC_LIBRARY_RELEASE webrtc PATHS ${VCPKG_INSTALL_ROOT}/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(WEBRTC_LIBRARY_DEBUG webrtc PATHS ${VCPKG_INSTALL_ROOT}/debug/lib NO_DEFAULT_PATH)
|
||||||
|
select_library_configurations(WEBRTC)
|
||||||
|
target_link_libraries(${TARGET_NAME} ${WEBRTC_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
NSString* defaultBuildTag = [json valueForKey:@"default_tag"];
|
NSString* defaultBuildTag = [json valueForKey:@"default_tag"];
|
||||||
|
|
||||||
NSString* launcherVersion = [launcherValues valueForKey:@"version"];
|
NSString* launcherVersion = [launcherValues valueForKey:@"version"];
|
||||||
NSString* launcherUrl = [[launcherValues valueForKey:@"mac"] valueForKey:@"url"];
|
NSString* launcherUrl = [[[launcherValues valueForKey:@"mac"] valueForKey:@"url"] stringByRemovingPercentEncoding];
|
||||||
|
|
||||||
BOOL appDirectoryExist = [fileManager fileExistsAtPath:[[sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]];
|
BOOL appDirectoryExist = [fileManager fileExistsAtPath:[[sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]];
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,10 @@ void OffscreenSurface::setMaxFps(uint8_t maxFps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenSurface::load(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback) {
|
void OffscreenSurface::load(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback) {
|
||||||
|
loadFromQml(qmlSource, parent, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OffscreenSurface::loadFromQml(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback) {
|
||||||
loadInternal(qmlSource, false, parent, [callback](QQmlContext* context, QQuickItem* newItem) {
|
loadInternal(qmlSource, false, parent, [callback](QQmlContext* context, QQuickItem* newItem) {
|
||||||
QJSValue(callback).call(QJSValueList() << context->engine()->newQObject(newItem));
|
QJSValue(callback).call(QJSValueList() << context->engine()->newQObject(newItem));
|
||||||
});
|
});
|
||||||
|
|
|
@ -111,6 +111,7 @@ signals:
|
||||||
void rootItemCreated(QQuickItem* rootContext);
|
void rootItemCreated(QQuickItem* rootContext);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void loadFromQml(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback);
|
||||||
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
||||||
bool filterEnabled(QObject* originalDestination, QEvent* event) const;
|
bool filterEnabled(QObject* originalDestination, QEvent* event) const;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
#include <QtScriptTools/QScriptEngineDebugger>
|
#include <QtScriptTools/QScriptEngineDebugger>
|
||||||
|
|
||||||
|
#include <shared/LocalFileAccessGate.h>
|
||||||
#include <shared/QtHelpers.h>
|
#include <shared/QtHelpers.h>
|
||||||
#include <AudioConstants.h>
|
#include <AudioConstants.h>
|
||||||
#include <AudioEffectOptions.h>
|
#include <AudioEffectOptions.h>
|
||||||
|
@ -1123,6 +1124,12 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEngine::run() {
|
void ScriptEngine::run() {
|
||||||
|
if (QThread::currentThread() != qApp->thread() && _context == Context::CLIENT_SCRIPT) {
|
||||||
|
// Flag that we're allowed to access local HTML files on UI created from C++ calls on this thread
|
||||||
|
// (because we're a client script)
|
||||||
|
hifi::scripting::setLocalAccessSafeThread(true);
|
||||||
|
}
|
||||||
|
|
||||||
auto filenameParts = _fileNameString.split("/");
|
auto filenameParts = _fileNameString.split("/");
|
||||||
auto name = filenameParts.size() > 0 ? filenameParts[filenameParts.size() - 1] : "unknown";
|
auto name = filenameParts.size() > 0 ? filenameParts[filenameParts.size() - 1] : "unknown";
|
||||||
PROFILE_SET_THREAD_NAME("Script: " + name);
|
PROFILE_SET_THREAD_NAME("Script: " + name);
|
||||||
|
@ -1300,6 +1307,9 @@ void ScriptEngine::run() {
|
||||||
|
|
||||||
emit finished(_fileNameString, qSharedPointerCast<ScriptEngine>(sharedFromThis()));
|
emit finished(_fileNameString, qSharedPointerCast<ScriptEngine>(sharedFromThis()));
|
||||||
|
|
||||||
|
// Don't leave our local-file-access flag laying around, reset it to false when the scriptengine
|
||||||
|
// thread is finished
|
||||||
|
hifi::scripting::setLocalAccessSafeThread(false);
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
emit runningStateChanged();
|
emit runningStateChanged();
|
||||||
emit doneRunning();
|
emit doneRunning();
|
||||||
|
|
21
libraries/shared/src/shared/LocalFileAccessGate.cpp
Normal file
21
libraries/shared/src/shared/LocalFileAccessGate.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2019/09/05
|
||||||
|
// Copyright 2013-2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "LocalFileAccessGate.h"
|
||||||
|
|
||||||
|
#include <QtCore/QThreadStorage>
|
||||||
|
|
||||||
|
static QThreadStorage<bool> localAccessSafe;
|
||||||
|
|
||||||
|
void hifi::scripting::setLocalAccessSafeThread(bool safe) {
|
||||||
|
localAccessSafe.setLocalData(safe);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hifi::scripting::isLocalAccessSafeThread() {
|
||||||
|
return localAccessSafe.hasLocalData() && localAccessSafe.localData();
|
||||||
|
}
|
21
libraries/shared/src/shared/LocalFileAccessGate.h
Normal file
21
libraries/shared/src/shared/LocalFileAccessGate.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2019/09/05
|
||||||
|
// Copyright 2013-2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef hifi_LocalFileAccessGate_h
|
||||||
|
#define hifi_LocalFileAccessGate_h
|
||||||
|
|
||||||
|
namespace hifi { namespace scripting {
|
||||||
|
|
||||||
|
void setLocalAccessSafeThread(bool safe = true);
|
||||||
|
|
||||||
|
bool isLocalAccessSafeThread();
|
||||||
|
|
||||||
|
}} // namespace hifi::scripting
|
||||||
|
|
||||||
|
#endif
|
|
@ -42,6 +42,7 @@
|
||||||
#include <NetworkAccessManager.h>
|
#include <NetworkAccessManager.h>
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
#include <AudioClient.h>
|
#include <AudioClient.h>
|
||||||
|
#include <shared/LocalFileAccessGate.h>
|
||||||
|
|
||||||
#include <gl/OffscreenGLCanvas.h>
|
#include <gl/OffscreenGLCanvas.h>
|
||||||
#include <gl/GLHelpers.h>
|
#include <gl/GLHelpers.h>
|
||||||
|
@ -814,4 +815,24 @@ void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OffscreenQmlSurface::loadFromQml(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback) {
|
||||||
|
auto objectCallback = [callback](QQmlContext* context, QQuickItem* newItem) {
|
||||||
|
QJSValue(callback).call(QJSValueList() << context->engine()->newQObject(newItem));
|
||||||
|
};
|
||||||
|
|
||||||
|
if (hifi::scripting::isLocalAccessSafeThread()) {
|
||||||
|
// If this is a
|
||||||
|
auto contextCallback = [callback](QQmlContext* context) {
|
||||||
|
ContextAwareProfile::restrictContext(context, false);
|
||||||
|
#if !defined(Q_OS_ANDROID)
|
||||||
|
FileTypeProfile::registerWithContext(context);
|
||||||
|
HFWebEngineProfile::registerWithContext(context);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
loadInternal(qmlSource, true, parent, objectCallback, contextCallback);
|
||||||
|
} else {
|
||||||
|
loadInternal(qmlSource, false, parent, objectCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#include "OffscreenQmlSurface.moc"
|
#include "OffscreenQmlSurface.moc"
|
||||||
|
|
|
@ -37,8 +37,8 @@ public:
|
||||||
Q_INVOKABLE void lowerKeyboard();
|
Q_INVOKABLE void lowerKeyboard();
|
||||||
PointerEvent::EventType choosePointerEventType(QEvent::Type type);
|
PointerEvent::EventType choosePointerEventType(QEvent::Type type);
|
||||||
Q_INVOKABLE unsigned int deviceIdByTouchPoint(qreal x, qreal y);
|
Q_INVOKABLE unsigned int deviceIdByTouchPoint(qreal x, qreal y);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void focusObjectChanged(QObject* newFocus);
|
void focusObjectChanged(QObject* newFocus);
|
||||||
void focusTextChanged(bool focusText);
|
void focusTextChanged(bool focusText);
|
||||||
|
@ -61,6 +61,7 @@ public slots:
|
||||||
void sendToQml(const QVariant& message);
|
void sendToQml(const QVariant& message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void loadFromQml(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback) override;
|
||||||
void clearFocusItem();
|
void clearFocusItem();
|
||||||
void setFocusText(bool newFocusText);
|
void setFocusText(bool newFocusText);
|
||||||
void initializeEngine(QQmlEngine* engine) override;
|
void initializeEngine(QQmlEngine* engine) override;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QtQml/QQmlProperty>
|
#include <QtQml/QQmlProperty>
|
||||||
|
|
||||||
#include <shared/QtHelpers.h>
|
#include <shared/QtHelpers.h>
|
||||||
|
#include <shared/LocalFileAccessGate.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
|
@ -635,13 +636,24 @@ void TabletProxy::returnToPreviousApp() {
|
||||||
qCDebug(uiLogging) << "tablet cannot load QML because _qmlTabletRoot is null";
|
qCDebug(uiLogging) << "tablet cannot load QML because _qmlTabletRoot is null";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletProxy::loadQMLSource(const QVariant& path, bool resizable) {
|
void TabletProxy::loadQMLSource(const QVariant& path, bool resizable) {
|
||||||
|
// Capture whether the current script thread is allowed to load local HTML content,
|
||||||
|
// pass the information along to the real function
|
||||||
|
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "loadQMLSource", Q_ARG(QVariant, path), Q_ARG(bool, resizable));
|
QMetaObject::invokeMethod(this, "loadQMLSourceImpl", Q_ARG(QVariant, path), Q_ARG(bool, resizable), Q_ARG(bool, localSafeContext));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
loadQMLSourceImpl(path, resizable, localSafeContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabletProxy::loadQMLSourceImpl(const QVariant& path, bool resizable, bool localSafeContext) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
qCWarning(uiLogging) << __FUNCTION__ << "may not be called directly by scripts";
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
QObject* root = nullptr;
|
QObject* root = nullptr;
|
||||||
if (!_toolbarMode && _qmlTabletRoot) {
|
if (!_toolbarMode && _qmlTabletRoot) {
|
||||||
root = _qmlTabletRoot;
|
root = _qmlTabletRoot;
|
||||||
|
@ -650,7 +662,14 @@ void TabletProxy::loadQMLSource(const QVariant& path, bool resizable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root) {
|
if (root) {
|
||||||
|
// BUGZ-1398: tablet access to local HTML files from client scripts
|
||||||
|
// Here we TEMPORARILY mark the main thread as allowed to load local file content,
|
||||||
|
// because the thread that originally made the call is so marked.
|
||||||
|
if (localSafeContext) {
|
||||||
|
hifi::scripting::setLocalAccessSafeThread(true);
|
||||||
|
}
|
||||||
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, path));
|
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, path));
|
||||||
|
hifi::scripting::setLocalAccessSafeThread(false);
|
||||||
_state = State::QML;
|
_state = State::QML;
|
||||||
_currentPathLoaded = path;
|
_currentPathLoaded = path;
|
||||||
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
||||||
|
|
|
@ -291,6 +291,13 @@ public:
|
||||||
* to have it not resizable.
|
* to have it not resizable.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void loadQMLSource(const QVariant& path, bool resizable = false);
|
Q_INVOKABLE void loadQMLSource(const QVariant& path, bool resizable = false);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Internal function, do not call from scripts
|
||||||
|
* @function TabletProxy#loadQMLSourceImpl
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void loadQMLSourceImpl(const QVariant& path, bool resizable, bool localSafeContext);
|
||||||
|
|
||||||
// FIXME: This currently relies on a script initializing the tablet (hence the bool denoting success);
|
// FIXME: This currently relies on a script initializing the tablet (hence the bool denoting success);
|
||||||
// it should be initialized internally so it cannot fail
|
// it should be initialized internally so it cannot fail
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue