Merge pull request #1832 from birarda/script-timer

hide ScriptEngine calls from JS
This commit is contained in:
ZappoMan 2014-02-03 12:45:41 -08:00
commit c739c2452a
3 changed files with 6 additions and 5 deletions

View file

@ -4110,7 +4110,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
}
@ -334,4 +335,3 @@ void ScriptEngine::stopTimer(QTimer *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);