StelScriptMgr.cpp   StelScriptMgr.cpp 
skipping to change at line 136 skipping to change at line 136
if(StelSkyLayerMgr* smgr = GETSTELMODULE(StelSkyLayerMgr)) if(StelSkyLayerMgr* smgr = GETSTELMODULE(StelSkyLayerMgr))
objectValue = engine.newQObject(smgr); objectValue = engine.newQObject(smgr);
// For accessing star scale, twinkle etc. // For accessing star scale, twinkle etc.
objectValue = engine.newQObject(StelApp::getInstance().getCore()->ge tSkyDrawer()); objectValue = engine.newQObject(StelApp::getInstance().getCore()->ge tSkyDrawer());
engine.globalObject().setProperty("StelSkyDrawer", objectValue); engine.globalObject().setProperty("StelSkyDrawer", objectValue);
setScriptRate(1.0); setScriptRate(1.0);
engine.setProcessEventsInterval(10); engine.setProcessEventsInterval(10);
agent = new StelScriptEngineAgent(&engine);
engine.setAgent(agent);
} }
StelScriptMgr::~StelScriptMgr() StelScriptMgr::~StelScriptMgr()
{ {
} }
QStringList StelScriptMgr::getScriptList() QStringList StelScriptMgr::getScriptList()
{ {
QStringList scriptFiles; QStringList scriptFiles;
try try
skipping to change at line 364 skipping to change at line 368
// run that script // run that script
engine.evaluate(preprocessedScript); engine.evaluate(preprocessedScript);
scriptEnded(); scriptEnded();
return true; return true;
} }
void StelScriptMgr::stopScript() void StelScriptMgr::stopScript()
{ {
if (engine.isEvaluating()) if (engine.isEvaluating())
{ {
if (agent->getPauseScript()) {
agent->setPauseScript(false);
}
QString msg = QString("INFO: asking running script to exit") ; QString msg = QString("INFO: asking running script to exit") ;
emit(scriptDebug(msg)); emit(scriptDebug(msg));
//qDebug() << msg; //qDebug() << msg;
engine.abortEvaluation(); engine.abortEvaluation();
} }
scriptEnded(); scriptEnded();
} }
void StelScriptMgr::setScriptRate(float r) void StelScriptMgr::setScriptRate(float r)
{ {
skipping to change at line 392 skipping to change at line 399
// pre-calculate the new time rate in an effort to prevent there bei ng much latency // pre-calculate the new time rate in an effort to prevent there bei ng much latency
// between setting the script rate and the time rate. // between setting the script rate and the time rate.
float factor = r / currentScriptRate; float factor = r / currentScriptRate;
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
core->setTimeRate(core->getTimeRate() * factor); core->setTimeRate(core->getTimeRate() * factor);
GETSTELMODULE(StelMovementMgr)->setMovementSpeedFactor(core->getTime Rate()); GETSTELMODULE(StelMovementMgr)->setMovementSpeedFactor(core->getTime Rate());
engine.globalObject().setProperty("scriptRateReadOnly", r); engine.globalObject().setProperty("scriptRateReadOnly", r);
}
void StelScriptMgr::pauseScript() {
agent->setPauseScript(true);
}
void StelScriptMgr::resumeScript() {
agent->setPauseScript(false);
} }
double StelScriptMgr::getScriptRate() double StelScriptMgr::getScriptRate()
{ {
return engine.globalObject().property("scriptRateReadOnly").toNumber (); return engine.globalObject().property("scriptRateReadOnly").toNumber ();
} }
void StelScriptMgr::debug(const QString& msg) void StelScriptMgr::debug(const QString& msg)
{ {
emit(scriptDebug(msg)); emit(scriptDebug(msg));
skipping to change at line 487 skipping to change at line 503
} }
} }
else else
{ {
output += line; output += line;
output += '\n'; output += '\n';
} }
} }
return true; return true;
} }
StelScriptEngineAgent::StelScriptEngineAgent(QScriptEngine *engine)
: QScriptEngineAgent(engine)
{
isPaused = false;
}
void StelScriptEngineAgent::positionChange(qint64 scriptId, int lineNumber,
int columnNumber)
{
Q_UNUSED(scriptId);
Q_UNUSED(lineNumber);
Q_UNUSED(columnNumber);
while (isPaused) {
// TODO : sleep for 'processEventsInterval' time
QCoreApplication::processEvents();
}
}
 End of changes. 4 change blocks. 
0 lines changed or deleted 16 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/