mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
Fixed entity script reloads
This commit is contained in:
parent
166f7223d1
commit
1ab46f68e3
4 changed files with 18 additions and 9 deletions
|
@ -226,10 +226,7 @@ void EntityTreeRenderer::resetPersistentEntitiesScriptEngine() {
|
||||||
manager->stop();
|
manager->stop();
|
||||||
manager->waitTillDoneRunning();
|
manager->waitTillDoneRunning();
|
||||||
manager->disconnectNonEssentialSignals();
|
manager->disconnectNonEssentialSignals();
|
||||||
// TODO: script manager pointer is still in use somewhere after the cleanup in lambda.
|
manager->removeFromScriptEngines();
|
||||||
// To prevent memory leaks on multiple reloads we would need to find all the usages and remove them.
|
|
||||||
// Script engines are correctly deleted later during shutdown currently.
|
|
||||||
qDebug() << "_nonPersistentEntitiesScriptManager lambda finished, script manager pointer use count: " << manager.use_count();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_persistentEntitiesScriptManager = scriptManagerFactory(ScriptManager::ENTITY_CLIENT_SCRIPT, NO_SCRIPT,
|
_persistentEntitiesScriptManager = scriptManagerFactory(ScriptManager::ENTITY_CLIENT_SCRIPT, NO_SCRIPT,
|
||||||
|
@ -252,10 +249,7 @@ void EntityTreeRenderer::resetNonPersistentEntitiesScriptEngine() {
|
||||||
manager->stop();
|
manager->stop();
|
||||||
manager->waitTillDoneRunning();
|
manager->waitTillDoneRunning();
|
||||||
manager->disconnectNonEssentialSignals();
|
manager->disconnectNonEssentialSignals();
|
||||||
// TODO: script manager pointer is still in use somewhere after the cleanup in lambda.
|
manager->removeFromScriptEngines();
|
||||||
// To prevent memory leaks on multiple reloads we would need to find all the usages and remove them.
|
|
||||||
// Script engines are correctly deleted later during shutdown currently.
|
|
||||||
qDebug() << "_nonPersistentEntitiesScriptManager lambda finished, script manager pointer use count: " << manager.use_count();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_nonPersistentEntitiesScriptManager = scriptManagerFactory(ScriptManager::ENTITY_CLIENT_SCRIPT, NO_SCRIPT,
|
_nonPersistentEntitiesScriptManager = scriptManagerFactory(ScriptManager::ENTITY_CLIENT_SCRIPT, NO_SCRIPT,
|
||||||
|
|
|
@ -184,6 +184,8 @@ public:
|
||||||
|
|
||||||
void addScriptEngine(ScriptManagerPointer);
|
void addScriptEngine(ScriptManagerPointer);
|
||||||
|
|
||||||
|
void removeScriptEngine(ScriptManagerPointer);
|
||||||
|
|
||||||
ScriptGatekeeper scriptGatekeeper;
|
ScriptGatekeeper scriptGatekeeper;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -336,7 +338,6 @@ protected slots:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ScriptManagerPointer reloadScript(const QString& scriptName, bool isUserLoaded = true) { return loadScript(scriptName, isUserLoaded, false, false, true); }
|
ScriptManagerPointer reloadScript(const QString& scriptName, bool isUserLoaded = true) { return loadScript(scriptName, isUserLoaded, false, false, true); }
|
||||||
void removeScriptEngine(ScriptManagerPointer);
|
|
||||||
void onScriptEngineLoaded(const QString& scriptFilename);
|
void onScriptEngineLoaded(const QString& scriptFilename);
|
||||||
void quitWhenFinished();
|
void quitWhenFinished();
|
||||||
void onScriptEngineError(const QString& scriptFilename);
|
void onScriptEngineError(const QString& scriptFilename);
|
||||||
|
|
|
@ -519,6 +519,11 @@ void ScriptManager::waitTillDoneRunning(bool shutdown) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptManager::removeFromScriptEngines() {
|
||||||
|
Q_ASSERT(_scriptEngines);
|
||||||
|
_scriptEngines.toStrongRef()->removeScriptEngine(shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
QString ScriptManager::getFilename() const {
|
QString ScriptManager::getFilename() const {
|
||||||
QStringList fileNameParts = _fileNameString.split("/");
|
QStringList fileNameParts = _fileNameString.split("/");
|
||||||
QString lastPart;
|
QString lastPart;
|
||||||
|
|
|
@ -471,6 +471,15 @@ public:
|
||||||
*/
|
*/
|
||||||
void waitTillDoneRunning(bool shutdown = false);
|
void waitTillDoneRunning(bool shutdown = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes shared pointer to script engine from the list of all script engines.
|
||||||
|
*
|
||||||
|
* This allows deletion of the script engine once all shared pointer instances are gone.
|
||||||
|
* This function is called for entity script engines when they are being destroyed.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void removeFromScriptEngines();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Load a script from a given URL
|
* @brief Load a script from a given URL
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue