mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:49:12 +02:00
Fixed crash with asset scripting crash
This commit is contained in:
parent
ca577f2802
commit
6c1fd88fb1
3 changed files with 11 additions and 7 deletions
|
@ -43,7 +43,7 @@ STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
AssetScriptingInterface::AssetScriptingInterface(QObject* parent) : BaseAssetScriptingInterface(parent) {
|
AssetScriptingInterface::AssetScriptingInterface(ScriptManager* parent) : BaseAssetScriptingInterface(parent), _scriptManager(parent) {
|
||||||
qCDebug(scriptengine) << "AssetScriptingInterface::AssetScriptingInterface" << parent;
|
qCDebug(scriptengine) << "AssetScriptingInterface::AssetScriptingInterface" << parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ void AssetScriptingInterface::jsCallback(const ScriptValue& handler,
|
||||||
Q_ASSERT(thread() == QThread::currentThread());
|
Q_ASSERT(thread() == QThread::currentThread());
|
||||||
Q_ASSERT(engine);
|
Q_ASSERT(engine);
|
||||||
//V8TODO: which kind of script context guard needs to be used here?
|
//V8TODO: which kind of script context guard needs to be used here?
|
||||||
ScriptContextGuard scriptContextGuard(engine()->currentContext());
|
ScriptContextGuard scriptContextGuard(_scriptManager->engine()->currentContext());
|
||||||
auto errorValue = !error.toBool() ? engine()->nullValue() : error;
|
auto errorValue = !error.toBool() ? engine()->nullValue() : error;
|
||||||
JS_VERIFY(handler.isObject() && handler.property("callback").isFunction(),
|
JS_VERIFY(handler.isObject() && handler.property("callback").isFunction(),
|
||||||
QString("jsCallback -- .callback is not a function (%1)")
|
QString("jsCallback -- .callback is not a function (%1)")
|
||||||
|
|
|
@ -46,12 +46,15 @@
|
||||||
* @hifi-server-entity
|
* @hifi-server-entity
|
||||||
* @hifi-assignment-client
|
* @hifi-assignment-client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class ScriptManager;
|
||||||
|
|
||||||
/// Provides the <code><a href="https://apidocs.overte.org/Assets.html">Assets</a></code> scripting API
|
/// Provides the <code><a href="https://apidocs.overte.org/Assets.html">Assets</a></code> scripting API
|
||||||
class AssetScriptingInterface : public BaseAssetScriptingInterface, Scriptable {
|
class AssetScriptingInterface : public BaseAssetScriptingInterface, Scriptable {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
using Parent = BaseAssetScriptingInterface;
|
using Parent = BaseAssetScriptingInterface;
|
||||||
AssetScriptingInterface(QObject* parent = nullptr);
|
AssetScriptingInterface(ScriptManager* parent);
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* Called when an {@link Assets.uploadData} call is complete.
|
* Called when an {@link Assets.uploadData} call is complete.
|
||||||
|
@ -547,6 +550,7 @@ protected:
|
||||||
void jsCallback(const ScriptValue& handler, const ScriptValue& error, const QVariantMap& result);
|
void jsCallback(const ScriptValue& handler, const ScriptValue& error, const QVariantMap& result);
|
||||||
void jsCallback(const ScriptValue& handler, const ScriptValue& error, const ScriptValue& result);
|
void jsCallback(const ScriptValue& handler, const ScriptValue& error, const ScriptValue& result);
|
||||||
bool jsVerify(bool condition, const QString& error);
|
bool jsVerify(bool condition, const QString& error);
|
||||||
|
ScriptManager *_scriptManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AssetScriptingInterface_h
|
#endif // hifi_AssetScriptingInterface_h
|
||||||
|
|
|
@ -394,6 +394,7 @@ void ScriptManager::runInThread() {
|
||||||
workerThread->setObjectName(name);
|
workerThread->setObjectName(name);
|
||||||
_engine->setThread(workerThread);
|
_engine->setThread(workerThread);
|
||||||
moveToThread(workerThread);
|
moveToThread(workerThread);
|
||||||
|
_assetScriptingInterface->moveToThread(workerThread);
|
||||||
|
|
||||||
// NOTE: If you connect any essential signals for proper shutdown or cleanup of
|
// NOTE: If you connect any essential signals for proper shutdown or cleanup of
|
||||||
// the script engine, make sure to add code to "reconnect" them to the
|
// the script engine, make sure to add code to "reconnect" them to the
|
||||||
|
@ -884,10 +885,9 @@ void ScriptManager::run() {
|
||||||
hifi::scripting::setLocalAccessSafeThread(true);
|
hifi::scripting::setLocalAccessSafeThread(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (QThread::currentThread() != _assetScriptingInterface->thread()) {
|
||||||
//_engine->enterIsolateOnThisThread();
|
_assetScriptingInterface->moveToThread(QThread::currentThread());
|
||||||
|
}
|
||||||
_engine->compileTest();
|
|
||||||
|
|
||||||
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";
|
||||||
|
|
Loading…
Reference in a new issue