mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
use unique_ptr for Agent ScriptEngine
This commit is contained in:
parent
5df7ce7424
commit
bca00db4a8
2 changed files with 5 additions and 11 deletions
|
@ -153,11 +153,11 @@ void Agent::run() {
|
||||||
|
|
||||||
qDebug() << "Downloaded script:" << scriptContents;
|
qDebug() << "Downloaded script:" << scriptContents;
|
||||||
|
|
||||||
_scriptEngine = new ScriptEngine(scriptContents, _payload);
|
_scriptEngine = std::unique_ptr<ScriptEngine>(new ScriptEngine(scriptContents, _payload));
|
||||||
_scriptEngine->setParent(this); // be the parent of the script engine so it gets moved when we do
|
_scriptEngine->setParent(this); // be the parent of the script engine so it gets moved when we do
|
||||||
|
|
||||||
// setup an Avatar for the script to use
|
// setup an Avatar for the script to use
|
||||||
ScriptableAvatar scriptedAvatar(_scriptEngine);
|
ScriptableAvatar scriptedAvatar(_scriptEngine.get());
|
||||||
scriptedAvatar.setForceFaceTrackerConnected(true);
|
scriptedAvatar.setForceFaceTrackerConnected(true);
|
||||||
|
|
||||||
// call model URL setters with empty URLs so our avatar, if user, will have the default models
|
// call model URL setters with empty URLs so our avatar, if user, will have the default models
|
||||||
|
@ -202,17 +202,10 @@ void Agent::run() {
|
||||||
entityScriptingInterface->setEntityTree(_entityViewer.getTree());
|
entityScriptingInterface->setEntityTree(_entityViewer.getTree());
|
||||||
|
|
||||||
// wire up our additional agent related processing to the update signal
|
// wire up our additional agent related processing to the update signal
|
||||||
QObject::connect(_scriptEngine, &ScriptEngine::update, this, &Agent::processAgentAvatarAndAudio);
|
QObject::connect(_scriptEngine.get(), &ScriptEngine::update, this, &Agent::processAgentAvatarAndAudio);
|
||||||
|
|
||||||
_scriptEngine->run();
|
_scriptEngine->run();
|
||||||
setFinished(true);
|
setFinished(true);
|
||||||
|
|
||||||
// kill the avatar identity timer
|
|
||||||
delete _avatarIdentityTimer;
|
|
||||||
|
|
||||||
// delete the script engine
|
|
||||||
delete _scriptEngine;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Agent::setIsAvatar(bool isAvatar) {
|
void Agent::setIsAvatar(bool isAvatar) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#ifndef hifi_Agent_h
|
#ifndef hifi_Agent_h
|
||||||
#define hifi_Agent_h
|
#define hifi_Agent_h
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QtScript/QScriptEngine>
|
#include <QtScript/QScriptEngine>
|
||||||
|
@ -61,7 +62,7 @@ private slots:
|
||||||
void processAgentAvatarAndAudio(float deltaTime);
|
void processAgentAvatarAndAudio(float deltaTime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptEngine* _scriptEngine;
|
std::unique_ptr<ScriptEngine> _scriptEngine;
|
||||||
EntityEditPacketSender _entityEditSender;
|
EntityEditPacketSender _entityEditSender;
|
||||||
EntityTreeHeadlessViewer _entityViewer;
|
EntityTreeHeadlessViewer _entityViewer;
|
||||||
QTimer* _pingTimer;
|
QTimer* _pingTimer;
|
||||||
|
|
Loading…
Reference in a new issue