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 | auto newEngineSP = qSharedPointerCast<EntitiesScriptEngineProvider>(newEngine); | 457 | auto newEngineSP = qSharedPointerCast<EntitiesScriptEngineProvider>(newEngine); |
| 458 | DependencyManager::get<EntityScriptingInterface>()->setEntitiesScriptEngine(newEngineSP); | 458 | DependencyManager::get<EntityScriptingInterface>()->setEntitiesScriptEngine(newEngineSP); |
| 459 | 459 | ||
| 460 | disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, | 460 | if (_entitiesScriptEngine) { |
| 461 | this, &EntityScriptServer::updateEntityPPS); | 461 | disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, |
| 462 | this, &EntityScriptServer::updateEntityPPS); | ||
| 463 | } | ||
| 464 | |||
| 462 | _entitiesScriptEngine.swap(newEngine); | 465 | _entitiesScriptEngine.swap(newEngine); |
| 463 | connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, | 466 | connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, |
| 464 | this, &EntityScriptServer::updateEntityPPS); | 467 | this, &EntityScriptServer::updateEntityPPS); |
| @@ -489,6 +492,21 @@ void EntityScriptServer::shutdownScriptEngine() { · 24 unmodified lines | |||
| 489 | _shuttingDown = true; | 492 | _shuttingDown = true; |
| 490 | 493 | ||
| 491 | clear(); // always clear() on shutdown | 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 | void EntityScriptServer::addingEntity(const EntityItemID& entityID) { | 512 | void EntityScriptServer::addingEntity(const EntityItemID& entityID) { |
| @@ -561,18 +579,6 @@ void EntityScriptServer::handleOctreePacket(QSharedPointer<ReceivedMessage> mess · 66 unmodified lines | |||
| 561 | void EntityScriptServer::aboutToFinish() { | 579 | void EntityScriptServer::aboutToFinish() { |
| 562 | shutdownScriptEngine(); | 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 | DependencyManager::destroy<AssignmentParentFinder>(); | 582 | DependencyManager::destroy<AssignmentParentFinder>(); |
| 577 | 583 | ||
| 578 | DependencyManager::get<ResourceManager>()->cleanup(); | 584 | DependencyManager::get<ResourceManager>()->cleanup(); |