mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02: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;
|
||||
|
||||
_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
|
||||
|
||||
// setup an Avatar for the script to use
|
||||
ScriptableAvatar scriptedAvatar(_scriptEngine);
|
||||
ScriptableAvatar scriptedAvatar(_scriptEngine.get());
|
||||
scriptedAvatar.setForceFaceTrackerConnected(true);
|
||||
|
||||
// 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());
|
||||
|
||||
// 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();
|
||||
setFinished(true);
|
||||
|
||||
// kill the avatar identity timer
|
||||
delete _avatarIdentityTimer;
|
||||
|
||||
// delete the script engine
|
||||
delete _scriptEngine;
|
||||
|
||||
}
|
||||
|
||||
void Agent::setIsAvatar(bool isAvatar) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#ifndef hifi_Agent_h
|
||||
#define hifi_Agent_h
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <QtScript/QScriptEngine>
|
||||
|
@ -61,7 +62,7 @@ private slots:
|
|||
void processAgentAvatarAndAudio(float deltaTime);
|
||||
|
||||
private:
|
||||
ScriptEngine* _scriptEngine;
|
||||
std::unique_ptr<ScriptEngine> _scriptEngine;
|
||||
EntityEditPacketSender _entityEditSender;
|
||||
EntityTreeHeadlessViewer _entityViewer;
|
||||
QTimer* _pingTimer;
|
||||
|
|
Loading…
Reference in a new issue