diff --git a/interface/src/ui/EntityScriptServerLogDialog.cpp b/interface/src/ui/EntityScriptServerLogDialog.cpp index 5746a92748..bb79ed7ef3 100644 --- a/interface/src/ui/EntityScriptServerLogDialog.cpp +++ b/interface/src/ui/EntityScriptServerLogDialog.cpp @@ -18,18 +18,21 @@ EntityScriptServerLogDialog::EntityScriptServerLogDialog(QWidget* parent) : Base auto& packetReceiver = nodeList->getPacketReceiver(); packetReceiver.registerListener(PacketType::EntityServerScriptLog, this, "handleEntityServerScriptLogPacket"); - auto shouldEnableLog = [this] { - auto nodeList = DependencyManager::get(); - enableToEntityServerScriptLog(nodeList->getThisNodeCanRez() || nodeList->getThisNodeCanRezTmp()); - }; - QObject::connect(nodeList.data(), &NodeList::canRezChanged, this, shouldEnableLog); - QObject::connect(nodeList.data(), &NodeList::canRezTmpChanged, this, shouldEnableLog); + QObject::connect(nodeList.data(), &NodeList::nodeActivated, this, &EntityScriptServerLogDialog::nodeActivated); + QObject::connect(nodeList.data(), &NodeList::nodeKilled, this, &EntityScriptServerLogDialog::nodeKilled); + + QObject::connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptServerLogDialog::shouldEnableLog); + QObject::connect(nodeList.data(), &NodeList::canRezTmpChanged, this, &EntityScriptServerLogDialog::shouldEnableLog); shouldEnableLog(); } EntityScriptServerLogDialog::~EntityScriptServerLogDialog() { enableToEntityServerScriptLog(false); } +void EntityScriptServerLogDialog::shouldEnableLog() { + auto nodeList = DependencyManager::get(); + enableToEntityServerScriptLog(nodeList->getThisNodeCanRez() || nodeList->getThisNodeCanRezTmp()); +}; void EntityScriptServerLogDialog::enableToEntityServerScriptLog(bool enable) { auto nodeList = DependencyManager::get(); @@ -56,3 +59,16 @@ void EntityScriptServerLogDialog::handleEntityServerScriptLogPacket(QSharedPoint auto lines = QString::fromUtf8(message->readAll()); QMetaObject::invokeMethod(this, "appendLogLine", Q_ARG(QString, lines)); } + +void EntityScriptServerLogDialog::nodeActivated(SharedNodePointer activatedNode) { + if (_subscribed && activatedNode->getType() == NodeType::EntityScriptServer) { + _subscribed = false; + shouldEnableLog(); + } +} + +void EntityScriptServerLogDialog::nodeKilled(SharedNodePointer killedNode) { + if (killedNode->getType() == NodeType::EntityScriptServer) { + appendLogLine("====================== Connection to the Entity Script Server lost ======================"); + } +} diff --git a/interface/src/ui/EntityScriptServerLogDialog.h b/interface/src/ui/EntityScriptServerLogDialog.h index b19ca5b32c..8c68db036c 100644 --- a/interface/src/ui/EntityScriptServerLogDialog.h +++ b/interface/src/ui/EntityScriptServerLogDialog.h @@ -30,6 +30,11 @@ private slots: void enableToEntityServerScriptLog(bool enable); void handleEntityServerScriptLogPacket(QSharedPointer message, SharedNodePointer senderNode); + void nodeActivated(SharedNodePointer activatedNode); + void nodeKilled(SharedNodePointer killedNode); + + void shouldEnableLog(); + private: bool _subscribed { false }; };