don't allow calls to init, run, evaluate from JS

This commit is contained in:
Stephen Birarda 2014-02-03 10:33:31 -08:00
parent e2842ab7a4
commit 028eec7164
3 changed files with 7 additions and 6 deletions

View file

@ -4255,7 +4255,7 @@ void Application::loadScript(const QString& fileNameString) {
QThread* workerThread = new QThread(this);
// when the worker thread is started, call our engine's run..
connect(workerThread, SIGNAL(started()), scriptEngine, SLOT(run()));
connect(workerThread, &QThread::started, scriptEngine, &ScriptEngine::run);
// when the thread is terminated, add both scriptEngine and thread to the deleteLater queue
connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater()));

View file

@ -106,6 +106,7 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents) {
}
void ScriptEngine::init() {
qDebug() << "Init called!";
if (_isInitialized) {
return; // only initialize once
}
@ -342,5 +343,4 @@ void ScriptEngine::stopTimer(QTimer *timer) {
_timerFunctionMap.remove(timer);
delete timer;
}
}
}

View file

@ -60,13 +60,14 @@ public:
void setAvatarData(AvatarData* avatarData, const QString& objectName);
void init();
void run(); /// runs continuously until Agent.stop() is called
void evaluate(); /// initializes the engine, and evaluates the script, but then returns control to caller
void timerFired();
public slots:
void init();
void run(); /// runs continuously until Agent.stop() is called
void stop();
void evaluate(); /// initializes the engine, and evaluates the script, but then returns control to caller
QObject* setInterval(const QScriptValue& function, int intervalMS);
QObject* setTimeout(const QScriptValue& function, int timeoutMS);