Merge pull request #13536 from SimonWalton-HiFi/script-engine-thread-agent

ScriptsModel instances should be created & destroyed on the same thread (for Agent)
This commit is contained in:
John Conklin II 2018-08-03 13:32:11 -07:00 committed by GitHub
commit 243bd5ea69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View file

@ -827,10 +827,6 @@ void Agent::processAgentAvatarAudio() {
void Agent::aboutToFinish() {
setIsAvatar(false);// will stop timers for sending identity packets
if (_scriptEngine) {
_scriptEngine->stop();
}
// our entity tree is going to go away so tell that to the EntityScriptingInterface
DependencyManager::get<EntityScriptingInterface>()->setEntityTree(nullptr);
@ -843,7 +839,6 @@ void Agent::aboutToFinish() {
// destroy all other created dependencies
DependencyManager::destroy<ScriptCache>();
DependencyManager::destroy<ScriptEngines>();
DependencyManager::destroy<ResourceCacheSharedItems>();
DependencyManager::destroy<SoundCacheScriptingInterface>();
@ -862,3 +857,11 @@ void Agent::aboutToFinish() {
_encoder = nullptr;
}
}
void Agent::stop() {
if (_scriptEngine) {
_scriptEngine->stop();
} else {
setFinished(true);
}
}

View file

@ -67,6 +67,8 @@ public slots:
void setIsAvatar(bool isAvatar);
bool isAvatar() const { return _isAvatar; }
Q_INVOKABLE virtual void stop() override;
private slots:
void requestScript();
void scriptRequestFinished();

View file

@ -120,7 +120,7 @@ void ThreadedAssignment::checkInWithDomainServerOrExit() {
if (_numQueuedCheckIns >= MAX_SILENT_DOMAIN_SERVER_CHECK_INS) {
qCDebug(networking) << "At least" << MAX_SILENT_DOMAIN_SERVER_CHECK_INS << "have been queued without a response from domain-server"
<< "Stopping the current assignment";
setFinished(true);
stop();
} else {
auto nodeList = DependencyManager::get<NodeList>();
QMetaObject::invokeMethod(nodeList.data(), "sendDomainServerCheckIn");
@ -132,5 +132,5 @@ void ThreadedAssignment::checkInWithDomainServerOrExit() {
void ThreadedAssignment::domainSettingsRequestFailed() {
qCDebug(networking) << "Failed to retreive settings object from domain-server. Bailing on assignment.";
setFinished(true);
stop();
}

View file

@ -24,7 +24,6 @@ public:
ThreadedAssignment(ReceivedMessage& message);
~ThreadedAssignment() { stop(); }
void setFinished(bool isFinished);
virtual void aboutToFinish() { };
void addPacketStatsAndSendStatsPacket(QJsonObject statsObject);
@ -43,6 +42,7 @@ signals:
protected:
void commonInit(const QString& targetName, NodeType_t nodeType);
void setFinished(bool isFinished);
bool _isFinished;
QTimer _domainServerTimer;