Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 3 files). Show all
Unified · Split
| @@ -457,8 +457,11 @@ void EntityScriptServer::resetEntitiesScriptEngine() { · 456 unmodified lines | ||
| 457 | 457 | auto newEngineSP = qSharedPointerCast<EntitiesScriptEngineProvider>(newEngine); |
| 458 | 458 | DependencyManager::get<EntityScriptingInterface>()->setEntitiesScriptEngine(newEngineSP); |
| 459 | 459 | |
| 460 | − disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, | |
| 461 | − this, &EntityScriptServer::updateEntityPPS); | |
| 460 | + if (_entitiesScriptEngine) { | |
| 461 | + disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, | |
| 462 | + this, &EntityScriptServer::updateEntityPPS); | |
| 463 | + } | |
| 464 | + | |
| 462 | 465 | _entitiesScriptEngine.swap(newEngine); |
| 463 | 466 | connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, |
| 464 | 467 | this, &EntityScriptServer::updateEntityPPS); |
| @@ -489,6 +492,21 @@ void EntityScriptServer::shutdownScriptEngine() { · 24 unmodified lines | ||
| 489 | 492 | _shuttingDown = true; |
| 490 | 493 | |
| 491 | 494 | clear(); // always clear() on shutdown |
| 495 | + | |
| 496 | + auto scriptEngines = DependencyManager::get<ScriptEngines>(); | |
| 497 | + scriptEngines->shutdownScripting(); | |
| 498 | + | |
| 499 | + _entitiesScriptEngine.clear(); | |
| 500 | + | |
| 501 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 502 | + // our entity tree is going to go away so tell that to the EntityScriptingInterface | |
| 503 | + entityScriptingInterface->setEntityTree(nullptr); | |
| 504 | + | |
| 505 | + // Should always be true as they are singletons. | |
| 506 | + if (entityScriptingInterface->getPacketSender() == &_entityEditSender) { | |
| 507 | + // The packet sender is about to go away. | |
| 508 | + entityScriptingInterface->setPacketSender(nullptr); | |
| 509 | + } | |
| 492 | 510 | } |
| 493 | 511 | |
| 494 | 512 | void EntityScriptServer::addingEntity(const EntityItemID& entityID) { |
| @@ -561,18 +579,6 @@ void EntityScriptServer::handleOctreePacket(QSharedPointer<ReceivedMessage> mess · 66 unmodified lines | ||
| 561 | 579 | void EntityScriptServer::aboutToFinish() { |
| 562 | 580 | shutdownScriptEngine(); |
| 563 | 581 | |
| 564 | − { | |
| 565 | − auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 566 | − // our entity tree is going to go away so tell that to the EntityScriptingInterface | |
| 567 | − entityScriptingInterface->setEntityTree(nullptr); | |
| 568 | − | |
| 569 | − // Should always be true as they are singletons. | |
| 570 | − if (entityScriptingInterface->getPacketSender() == &_entityEditSender) { | |
| 571 | − // The packet sender is about to go away. | |
| 572 | − entityScriptingInterface->setPacketSender(nullptr); | |
| 573 | − } | |
| 574 | − } | |
| 575 | − | |
| 576 | 582 | DependencyManager::destroy<AssignmentParentFinder>(); |
| 577 | 583 | |
| 578 | 584 | DependencyManager::get<ResourceManager>()->cleanup(); |