mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
V8-related cleanup
This commit is contained in:
parent
30f4608c25
commit
3c80411bf1
14 changed files with 5 additions and 62 deletions
|
@ -53,7 +53,6 @@ PickResultPointer LaserPointer::getPickResultCopy(const PickResultPointer& pickR
|
|||
}
|
||||
|
||||
QVariantMap LaserPointer::toVariantMap() const {
|
||||
//V8TODO: this cannot be done anymore without script engine
|
||||
QVariantMap qVariantMap = Parent::toVariantMap();
|
||||
|
||||
QVariantMap qRenderStates;
|
||||
|
|
|
@ -542,7 +542,7 @@ std::shared_ptr<Pointer> PointerScriptingInterface::buildParabolaPointer(const P
|
|||
}
|
||||
|
||||
void PointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const {
|
||||
//V8TODO: this won't work for now
|
||||
//V8TODO: this needs testing
|
||||
QVariantMap propMap = properties.toMap();
|
||||
|
||||
QVariant startProps;
|
||||
|
|
|
@ -51,8 +51,7 @@ STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
|
|||
RayToOverlayIntersectionResultFromScriptValue>(scriptEngine);
|
||||
}));
|
||||
|
||||
// V8TODO: _scriptEngine can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
Overlays::Overlays() /*: _scriptEngine(newScriptEngine())*/ {
|
||||
Overlays::Overlays() {
|
||||
ADD_TYPE_MAP(Box, cube);
|
||||
ADD_TYPE_MAP(Sphere, sphere);
|
||||
_overlayToEntityTypes["rectangle3d"] = "Shape";
|
||||
|
@ -310,12 +309,6 @@ QString Overlays::entityToOverlayType(const QString& type) {
|
|||
|
||||
static QHash<QUuid, std::pair<glm::quat, bool>> savedRotations = QHash<QUuid, std::pair<glm::quat, bool>>();
|
||||
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
/*EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, const QString& type, bool add, const QUuid& id) {
|
||||
std::pair<glm::quat, bool> rotation;
|
||||
return convertOverlayToEntityProperties(overlayProps, rotation, type, add, id);
|
||||
}*/
|
||||
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
/*EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair<glm::quat, bool>& rotationToSave, const QString& type, bool add, const QUuid& id) {
|
||||
overlayProps["type"] = type;
|
||||
|
@ -815,22 +808,6 @@ QUuid Overlays::addOverlay(const QString& type, const QVariant& properties) {
|
|||
}
|
||||
|
||||
return UNKNOWN_ENTITY_ID;
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
/*QString entityType = overlayToEntityType(type);
|
||||
if (entityType == "Unknown") {
|
||||
return UNKNOWN_ENTITY_ID;
|
||||
}
|
||||
|
||||
QVariantMap propertyMap = properties.toMap();
|
||||
if (type == "rectangle3d") {
|
||||
propertyMap["shape"] = "Quad";
|
||||
}
|
||||
std::pair<glm::quat, bool> rotationToSave;
|
||||
QUuid id = DependencyManager::get<EntityScriptingInterface>()->addEntityInternal(convertOverlayToEntityProperties(propertyMap, rotationToSave, entityType, true), entity::HostType::LOCAL);
|
||||
if (entityType == "Text" || entityType == "Image" || entityType == "Grid" || entityType == "Web") {
|
||||
savedRotations[id] = rotationToSave;
|
||||
}
|
||||
return id;*/
|
||||
}
|
||||
|
||||
QUuid Overlays::add2DOverlay(const Overlay::Pointer& overlay) {
|
||||
|
@ -889,13 +866,6 @@ bool Overlays::editOverlay(const QUuid& id, const QVariant& properties) {
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
/*
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
auto propertyMap = properties.toMap();
|
||||
EntityItemProperties entityProperties = convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id);
|
||||
return !entityScriptingInterface->editEntity(id, entityProperties).isNull();*/
|
||||
}
|
||||
|
||||
bool Overlays::editOverlays(const QVariant& propertiesById) {
|
||||
|
@ -907,7 +877,6 @@ bool Overlays::editOverlays(const QVariant& propertiesById) {
|
|||
|
||||
QVariantMap deferred;
|
||||
const QVariantMap map = propertiesById.toMap();
|
||||
//auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
for (const auto& key : map.keys()) {
|
||||
QUuid id = QUuid(key);
|
||||
const QVariant& properties = map[key];
|
||||
|
@ -921,9 +890,6 @@ bool Overlays::editOverlays(const QVariant& propertiesById) {
|
|||
overlay->setProperties(properties.toMap());
|
||||
} else {
|
||||
qDebug() << "Overlays::editOverlays doesn't support editing entities anymore";
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
/*auto propertyMap = properties.toMap();
|
||||
entityScriptingInterface->editEntity(id, convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id));*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,9 +123,6 @@ public:
|
|||
|
||||
void cleanupAllOverlays();
|
||||
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
//mutable ScriptEnginePointer _scriptEngine;
|
||||
|
||||
public slots:
|
||||
/*@jsdoc
|
||||
* Adds an overlay to the scene.
|
||||
|
@ -763,16 +760,9 @@ private:
|
|||
QMouseEvent* event, PointerEvent::EventType eventType);
|
||||
|
||||
static QString entityToOverlayType(const QString& type);
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
//static QString overlayToEntityType(const QString& type);
|
||||
static std::unordered_map<QString, QString> _entityToOverlayTypes;
|
||||
static std::unordered_map<QString, QString> _overlayToEntityTypes;
|
||||
|
||||
// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts
|
||||
/*QVariantMap convertEntityToOverlayProperties(const EntityItemProperties& entityProps);
|
||||
EntityItemProperties convertOverlayToEntityProperties(QVariantMap& overlayProps, const QString& type, bool add, const QUuid& id);
|
||||
EntityItemProperties convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair<glm::quat, bool>& rotationToSave, const QString& type, bool add, const QUuid& id = QUuid());*/
|
||||
|
||||
private slots:
|
||||
void mousePressOnPointerEvent(const QUuid& id, const PointerEvent& event);
|
||||
void mousePressOffPointerEvent();
|
||||
|
|
|
@ -1680,6 +1680,7 @@ bool EntityScriptingInterface::getServerScriptStatus(const QUuid& entityID, Scri
|
|||
auto engine = callback.engine();
|
||||
// V8TODO: it seems to sometimes be called on a wrong thread, reading to script engine crashes. I added an assert for now.
|
||||
// V8TODO: somehow the asserts are not happening here, but destructor still runs on main thread sometimes and deadlocks.
|
||||
// V8TODO: I think this was fixed? Should be tested
|
||||
Q_ASSERT(QThread::currentThread() == engine->thread());
|
||||
Q_ASSERT(QThread::currentThread() == engine->manager()->thread());
|
||||
QString statusString = EntityScriptStatus_::valueToKey(request->getStatus());
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "ScriptException.h"
|
||||
|
||||
// These are used for debugging memory leaks caused by persistent handles
|
||||
// V8TODO: Rename to something better, like for example OVERTE_V8_MEMORY_DEBUG
|
||||
#define OVERTE_V8_MEMORY_DEBUG
|
||||
|
||||
class QByteArray;
|
||||
|
|
|
@ -119,8 +119,6 @@ public:
|
|||
inline QObject* toQObject() const;
|
||||
|
||||
protected:
|
||||
//V8TODO
|
||||
//Won't a regular pointer cause memory leak?
|
||||
ScriptValueProxy* _proxy;
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ScriptValue::PropertyFlags);
|
||||
|
|
|
@ -282,7 +282,7 @@ bool vec3FromScriptValue(const ScriptValue& object, glm::vec3& vec3) {
|
|||
}
|
||||
|
||||
if (!x.isValid() || !y.isValid() || !z.isValid()) {
|
||||
// V8TODO: This breaks the sit script for some reason
|
||||
// V8TODO: This breaks the sit script because in our API valid Vec3 can be created from just 2 values
|
||||
//return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -421,7 +421,6 @@ private:
|
|||
const glm::vec3& UP() { return Vectors::UP; }
|
||||
const glm::vec3& FRONT() { return Vectors::FRONT; }
|
||||
|
||||
//V8TODO delete after V8 works - used only for debugging
|
||||
public:
|
||||
virtual ~Vec3();
|
||||
};
|
||||
|
|
|
@ -221,6 +221,7 @@ void XMLHttpRequestClass::requestFinished() {
|
|||
_rawResponseData.append(_reply->readAll());
|
||||
|
||||
if (_responseType == "json") {
|
||||
// V8TODO: V8 JSON parser needs to be used instead
|
||||
_responseData = _engine->evaluate("(" + QString(_rawResponseData.data()) + ")");
|
||||
if (_responseData.isError()) {
|
||||
_engine->clearExceptions();
|
||||
|
|
|
@ -966,7 +966,6 @@ ScriptValue ScriptEngineV8::newArrayBuffer(const QByteArray& message) {
|
|||
v8::Isolate::Scope isolateScope(_v8Isolate);
|
||||
v8::HandleScope handleScope(_v8Isolate);
|
||||
v8::Context::Scope contextScope(getContext());
|
||||
//V8TODO: this will leak memory
|
||||
std::shared_ptr<v8::BackingStore> backingStore(v8::ArrayBuffer::NewBackingStore(_v8Isolate, message.size()));
|
||||
std::memcpy(backingStore.get()->Data(), message.constData(), message.size());
|
||||
auto arrayBuffer = v8::ArrayBuffer::New(_v8Isolate, backingStore);
|
||||
|
|
|
@ -213,7 +213,6 @@ ScriptObjectV8Proxy::~ScriptObjectV8Proxy() {
|
|||
v8::HandleScope handleScope(isolate);
|
||||
if (_object)
|
||||
qCDebug(scriptengine_v8) << "Deleting object proxy: " << name();
|
||||
// V8TODO: once WeakPersistent pointer is added we should check if it's valid before deleting
|
||||
Q_ASSERT(!_v8Object.Get(isolate)->IsNullOrUndefined());
|
||||
// This prevents unwrap function from unwrapping proxy that was deleted
|
||||
_v8Object.Get(isolate)->SetAlignedPointerInInternalField(0, const_cast<void*>(internalPointsToDeletedQObjectProxy));
|
||||
|
@ -359,9 +358,7 @@ void ScriptObjectV8Proxy::investigate() {
|
|||
v8Object->SetInternalField(2, propertiesObject);
|
||||
|
||||
// Add all the methods objects as properties - this allows adding properties to a given method later. Is used by Script.request.
|
||||
// V8TODO: Should these be deleted when the script-owned object is destroyed? It needs checking if script-owned objects will be garbage-collected, or will self-referencing prevent it.
|
||||
for (auto i = _methods.begin(); i != _methods.end(); i++) {
|
||||
//V8TODO: lifetime may prevent garbage collection?
|
||||
V8ScriptValue method = ScriptMethodV8Proxy::newMethod(_engine, qobject, V8ScriptValue(_engine, v8Object),
|
||||
i.value().methods, i.value().numMaxParams);
|
||||
if(!propertiesObject->Set(_engine->getContext(), v8::String::NewFromUtf8(isolate, i.value().name.toStdString().c_str()).ToLocalChecked(), method.get()).FromMaybe(false)) {
|
||||
|
|
|
@ -101,7 +101,6 @@ private: // helper functions
|
|||
|
||||
private: // storage
|
||||
ScriptEngineV8 *_engine;
|
||||
//V8TODO: this needs a persistent handle instead, maybe with set weak?
|
||||
V8ScriptValue _value;
|
||||
|
||||
Q_DISABLE_COPY(ScriptValueV8Wrapper)
|
||||
|
|
|
@ -37,13 +37,8 @@
|
|||
// # define WEBRTC_POSIX 1
|
||||
// # define WEBRTC_LEGACY 1
|
||||
#elif defined(Q_OS_LINUX) && defined(Q_PROCESSOR_X86_64)
|
||||
//V8TODO:
|
||||
// WEBRTC_AUDIO causes:
|
||||
// overte/libraries/audio-client/src/AudioClient.cpp:1258:36: runtime error: member call on address 0x61b000006980 which does not point to an object of type 'AudioProcessing'
|
||||
// 0x61b000006980: note: object has invalid vptr
|
||||
# define WEBRTC_AUDIO 1
|
||||
# define WEBRTC_POSIX 1
|
||||
//V8TODO: temporarily disabled, because linker failed for memory debugging
|
||||
# define WEBRTC_DATA_CHANNELS 1
|
||||
#elif defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM)
|
||||
// WebRTC is basically impossible to build on aarch64 Linux.
|
||||
|
|
Loading…
Reference in a new issue