mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-08 10:28:03 +02:00
cleanup
This commit is contained in:
parent
a4f562672a
commit
d1f6b371c9
3 changed files with 4 additions and 73 deletions
|
@ -1156,9 +1156,6 @@ void Application::aboutToQuit() {
|
|||
}
|
||||
|
||||
void Application::cleanupBeforeQuit() {
|
||||
qDebug() << __FUNCTION__ << "----- START -----";
|
||||
|
||||
|
||||
// add a logline indicating if QTWEBENGINE_REMOTE_DEBUGGING is set or not
|
||||
QString webengineRemoteDebugging = QProcessEnvironment::systemEnvironment().value("QTWEBENGINE_REMOTE_DEBUGGING", "false");
|
||||
qCDebug(interfaceapp) << "QTWEBENGINE_REMOTE_DEBUGGING =" << webengineRemoteDebugging;
|
||||
|
@ -1190,18 +1187,12 @@ void Application::cleanupBeforeQuit() {
|
|||
// tell the packet receiver we're shutting down, so it can drop packets
|
||||
nodeList->getPacketReceiver().setShouldDropPackets(true);
|
||||
|
||||
qDebug() << __FUNCTION__ << "about to call getEntities()->shutdown();";
|
||||
getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
|
||||
|
||||
getEntities()->clear(); // this will allow entity scripts to properly shutdown
|
||||
//DependencyManager::destroy<EntityTreeRenderer>();
|
||||
qDebug() << __FUNCTION__ << "AFTER call to getEntities()->shutdown();";
|
||||
|
||||
qDebug() << __FUNCTION__ << "about to shutdown ScriptEngines...";
|
||||
DependencyManager::get<ScriptEngines>()->saveScripts();
|
||||
DependencyManager::get<ScriptEngines>()->shutdownScripting(); // stop all currently running global scripts
|
||||
DependencyManager::destroy<ScriptEngines>();
|
||||
qDebug() << __FUNCTION__ << "AFTER shutdown ScriptEngines...";
|
||||
|
||||
// first stop all timers directly or by invokeMethod
|
||||
// depending on what thread they run in
|
||||
|
@ -1211,15 +1202,11 @@ void Application::cleanupBeforeQuit() {
|
|||
pingTimer.stop();
|
||||
QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
|
||||
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__;
|
||||
|
||||
// save state
|
||||
_settingsThread.quit();
|
||||
saveSettings();
|
||||
_window->saveGeometry();
|
||||
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__;
|
||||
|
||||
// stop the AudioClient
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
|
||||
"stop", Qt::BlockingQueuedConnection);
|
||||
|
@ -1227,14 +1214,10 @@ void Application::cleanupBeforeQuit() {
|
|||
// destroy the AudioClient so it and its thread have a chance to go down safely
|
||||
DependencyManager::destroy<AudioClient>();
|
||||
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__;
|
||||
|
||||
// destroy the AudioInjectorManager so it and its thread have a chance to go down safely
|
||||
// this will also stop any ongoing network injectors
|
||||
DependencyManager::destroy<AudioInjectorManager>();
|
||||
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__;
|
||||
|
||||
// Destroy third party processes after scripts have finished using them.
|
||||
#ifdef HAVE_DDE
|
||||
DependencyManager::destroy<DdeFaceTracker>();
|
||||
|
@ -1243,11 +1226,7 @@ void Application::cleanupBeforeQuit() {
|
|||
DependencyManager::destroy<EyeTracker>();
|
||||
#endif
|
||||
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__;
|
||||
|
||||
DependencyManager::destroy<OffscreenUi>();
|
||||
|
||||
qDebug() << __FUNCTION__ << " ----- END -----";
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
|
@ -4218,9 +4197,7 @@ void Application::clearDomainOctreeDetails() {
|
|||
});
|
||||
|
||||
// reset the model renderer
|
||||
qCDebug(interfaceapp) << __FUNCTION__ << " --- BEFORE getEntities()->clear() --- _aboutToQuit:" << _aboutToQuit;
|
||||
getEntities()->clear();
|
||||
qCDebug(interfaceapp) << __FUNCTION__ << " --- AFTER getEntities()->clear() ---";
|
||||
|
||||
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
||||
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME);
|
||||
|
@ -4229,13 +4206,9 @@ void Application::clearDomainOctreeDetails() {
|
|||
}
|
||||
|
||||
void Application::domainChanged(const QString& domainHostname) {
|
||||
qCDebug(interfaceapp) << __FUNCTION__ << " --- BEGIN --- domainHostname:" << domainHostname;
|
||||
|
||||
updateWindowTitle();
|
||||
//clearDomainOctreeDetails();
|
||||
// disable physics until we have enough information about our new location to not cause craziness.
|
||||
resetPhysicsReadyInformation();
|
||||
qCDebug(interfaceapp) << __FUNCTION__ << " --- END ---";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterf
|
|||
}
|
||||
|
||||
EntityTreeRenderer::~EntityTreeRenderer() {
|
||||
qDebug() << __FUNCTION__;
|
||||
// NOTE: We don't need to delete _entitiesScriptEngine because
|
||||
// it is registered with ScriptEngines, which will call deleteLater for us.
|
||||
}
|
||||
|
@ -79,27 +78,21 @@ EntityTreeRenderer::~EntityTreeRenderer() {
|
|||
int EntityTreeRenderer::_entititesScriptEngineCount = 0;
|
||||
|
||||
void EntityTreeRenderer::setupEntitiesScriptEngine() {
|
||||
qDebug() << __FUNCTION__ << "---- BEGIN ----";
|
||||
_entitiesScriptEngine = QSharedPointer<ScriptEngine>(new ScriptEngine(NO_SCRIPT, QString("Entities %1").arg(++_entititesScriptEngineCount)), ScriptEngine::doDeleteLater);
|
||||
_scriptingServices->registerScriptEngineWithApplicationServices(_entitiesScriptEngine.data());
|
||||
_entitiesScriptEngine->runInThread();
|
||||
DependencyManager::get<EntityScriptingInterface>()->setEntitiesScriptEngine(_entitiesScriptEngine.data());
|
||||
qDebug() << __FUNCTION__ << "---- END ----";
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::clear() {
|
||||
qDebug() << __FUNCTION__ << "---- BEGIN ----";
|
||||
leaveAllEntities();
|
||||
if (_entitiesScriptEngine) {
|
||||
_entitiesScriptEngine->unloadAllEntityScripts();
|
||||
}
|
||||
|
||||
// this would be a good place to actuall delete and recreate the _entitiesScriptEngine
|
||||
qDebug() << __FUNCTION__ << "_shuttingDown:" << _shuttingDown;
|
||||
if (_wantScripts && !_shuttingDown) {
|
||||
qDebug() << __FUNCTION__ << " about to _entitiesScriptEngine->stop()";
|
||||
_entitiesScriptEngine->stop();
|
||||
qDebug() << __FUNCTION__ << " AFTER _entitiesScriptEngine->stop()";
|
||||
|
||||
// NOTE: you can't actually need to delete it here because when we call setupEntitiesScriptEngine it will
|
||||
// assign a new instance to our shared pointer, which will deref the old instance and ultimately call
|
||||
|
@ -116,7 +109,6 @@ void EntityTreeRenderer::clear() {
|
|||
_entitiesInScene.clear();
|
||||
|
||||
OctreeRenderer::clear();
|
||||
qDebug() << __FUNCTION__ << "---- END ----";
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::reloadEntityScripts() {
|
||||
|
|
|
@ -142,10 +142,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam
|
|||
}
|
||||
|
||||
ScriptEngine::~ScriptEngine() {
|
||||
qCDebug(scriptengine) << __FUNCTION__ << "--- BEGIN --- script:" << getFilename();
|
||||
qCDebug(scriptengine) << __FUNCTION__ << "called on thread[" << QThread::currentThread() << "], object's thread [" << thread() << "] script:" << getFilename();
|
||||
qCDebug(scriptengine) << "Script Engine shutting down (destructor) for script:" << getFilename();
|
||||
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
if (scriptEngines) {
|
||||
qCDebug(scriptengine) << "About to remove ScriptEngine [" << getFilename() << "] from ScriptEngines!";
|
||||
|
@ -154,7 +151,6 @@ ScriptEngine::~ScriptEngine() {
|
|||
} else {
|
||||
qCWarning(scriptengine) << "Script destroyed after ScriptEngines!";
|
||||
}
|
||||
qCDebug(scriptengine) << __FUNCTION__ << "--- END --- script:" << getFilename();
|
||||
}
|
||||
|
||||
void ScriptEngine::disconnectNonEssentialSignals() {
|
||||
|
@ -1053,36 +1049,6 @@ void ScriptEngine::forwardHandlerCall(const EntityItemID& entityID, const QStrin
|
|||
// since all of these operations can be asynch we will always do the actual work in the response handler
|
||||
// for the download
|
||||
void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const EntityItemID& entityID, const QString& entityScript, bool forceRedownload) {
|
||||
|
||||
|
||||
/*****
|
||||
if (QThread::currentThread() != thread()) {
|
||||
#ifdef THREAD_DEBUGGING
|
||||
qDebug() << "*** WARNING *** ScriptEngine::loadEntityScript() called on wrong thread ["
|
||||
<< QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
|
||||
"entityID:" << entityID << "entityScript:" << entityScript <<"forceRedownload:" << forceRedownload;
|
||||
#endif
|
||||
|
||||
QMetaObject::invokeMethod(this, "loadEntityScript",
|
||||
Q_ARG(const EntityItemID&, entityID),
|
||||
Q_ARG(const QString&, entityScript),
|
||||
Q_ARG(bool, forceRedownload));
|
||||
return;
|
||||
}
|
||||
#ifdef THREAD_DEBUGGING
|
||||
qDebug() << "ScriptEngine::loadEntityScript() called on correct thread [" << thread() << "] "
|
||||
"entityID:" << entityID << "entityScript:" << entityScript << "forceRedownload:" << forceRedownload;
|
||||
#endif
|
||||
|
||||
// If we've been called our known entityScripts should not know about us..
|
||||
assert(!_entityScripts.contains(entityID));
|
||||
|
||||
#ifdef THREAD_DEBUGGING
|
||||
qDebug() << "ScriptEngine::loadEntityScript() calling scriptCache->getScriptContents() on thread ["
|
||||
<< QThread::currentThread() << "] expected thread [" << thread() << "]";
|
||||
#endif
|
||||
******/
|
||||
|
||||
// NOTE: If the script content is not currently in the caceh, The LAMBDA here, will be called on the Main Thread
|
||||
// which means we're guarenteed that it's not the correct thread for the ScriptEngine. This means
|
||||
// when we get into entityScriptContentAvailable() we will likely invokeMethod() to get it over
|
||||
|
@ -1090,15 +1056,15 @@ void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const
|
|||
DependencyManager::get<ScriptCache>()->getScriptContents(entityScript, [theEngine, entityID](const QString& scriptOrURL, const QString& contents, bool isURL, bool success) {
|
||||
QSharedPointer<ScriptEngine> strongEngine = theEngine.toStrongRef();
|
||||
if (strongEngine) {
|
||||
qDebug() << "ScriptCache::getScriptContents() returned ScriptEngine still active calling ... entityScriptContentAvailable()";
|
||||
#if 1//def THREAD_DEBUGGING
|
||||
#ifdef THREAD_DEBUGGING
|
||||
qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread ["
|
||||
<< QThread::currentThread() << "] expected thread [" << strongEngine->thread() << "]";
|
||||
#endif
|
||||
|
||||
|
||||
strongEngine->entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success);
|
||||
} else {
|
||||
// FIXME - I'm leaving this in for testing, so that QA can confirm that sometimes the script contents
|
||||
// returns after the ScriptEngine has been deleted, we can remove this after QA verifies the
|
||||
// repro case.
|
||||
qDebug() << "ScriptCache::getScriptContents() returned after our ScriptEngine was deleted...";
|
||||
}
|
||||
}, forceRedownload);
|
||||
|
|
Loading…
Reference in a new issue