mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-06 20:23:21 +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;
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ void AssetScriptingInterface::jsCallback(const ScriptValue& handler,
|
|||
Q_ASSERT(thread() == QThread::currentThread());
|
||||
Q_ASSERT(engine);
|
||||
//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;
|
||||
JS_VERIFY(handler.isObject() && handler.property("callback").isFunction(),
|
||||
QString("jsCallback -- .callback is not a function (%1)")
|
||||
|
|
|
@ -46,12 +46,15 @@
|
|||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*/
|
||||
|
||||
class ScriptManager;
|
||||
|
||||
/// Provides the <code><a href="https://apidocs.overte.org/Assets.html">Assets</a></code> scripting API
|
||||
class AssetScriptingInterface : public BaseAssetScriptingInterface, Scriptable {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Parent = BaseAssetScriptingInterface;
|
||||
AssetScriptingInterface(QObject* parent = nullptr);
|
||||
AssetScriptingInterface(ScriptManager* parent);
|
||||
|
||||
/*@jsdoc
|
||||
* 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 ScriptValue& result);
|
||||
bool jsVerify(bool condition, const QString& error);
|
||||
ScriptManager *_scriptManager;
|
||||
};
|
||||
|
||||
#endif // hifi_AssetScriptingInterface_h
|
||||
|
|
|
@ -394,6 +394,7 @@ void ScriptManager::runInThread() {
|
|||
workerThread->setObjectName(name);
|
||||
_engine->setThread(workerThread);
|
||||
moveToThread(workerThread);
|
||||
_assetScriptingInterface->moveToThread(workerThread);
|
||||
|
||||
// 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
|
||||
|
@ -884,10 +885,9 @@ void ScriptManager::run() {
|
|||
hifi::scripting::setLocalAccessSafeThread(true);
|
||||
}
|
||||
|
||||
|
||||
//_engine->enterIsolateOnThisThread();
|
||||
|
||||
_engine->compileTest();
|
||||
if (QThread::currentThread() != _assetScriptingInterface->thread()) {
|
||||
_assetScriptingInterface->moveToThread(QThread::currentThread());
|
||||
}
|
||||
|
||||
auto filenameParts = _fileNameString.split("/");
|
||||
auto name = filenameParts.size() > 0 ? filenameParts[filenameParts.size() - 1] : "unknown";
|
||||
|
|
Loading…
Reference in a new issue