bool MYScriptEng::InitEngine()
{
if (m_pEngine==NULL) {
m_pEngine = new QScriptEngine();
}
if (m_bDebugger && m_pDebugger==NULL) {
m_pDebugger = new QScriptEngineDebugger();
m_pDebugger->setAutoShowStandardWindow(true);
m_debugWindow = m_pDebugger->standardWindow();
m_debugWindow->setWindowModality(Qt::ApplicationModal);
m_pDebugger->attachTo(m_pEngine);
}
if (m_pEngine) {
// init the generic functions
m_pEngine->globalObject().setProperty("print", m_pEngine->newFunction(myprint, 1));
m_pEngine->globalObject().setProperty("alert", m_pEngine->newFunction(myalert, 1));
if (m_pMyWgt != NULL) {
QScriptValue MyObj
= m_pEngine
->newQObject
((QObject*)m_pMyWgt
);
m_pEngine->globalObject().setProperty("page", MyObj );
}
m_pEngine->setProcessEventsInterval(100);
}
return true;
}
void MyScriptEng::Init(MyWidget* pWgt)
{
if (m_bDebugger)//If debugger is available
{
m_pDebugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
m_pExitAction= m_pDebugger->action(QScriptEngineDebugger::ContinueAction);
}
if(m_pEngine){
QScriptValue ret = m_pEngine->evaluate(m_strContents);
if (ret.isError()) {
// reportScriptError(ret);
// todo: display error
}
}
}
void MyScriptEng::Deinit()
{
if(m_pEngine){
if(m_pDebugger && m_pDebugger->state()==QScriptEngineDebugger::RunningState)
{
m_pExitAction->trigger();//IS this enough to continue the debugger
m_debugWindow->close();
qApp->processEvents();
}
bool MYScriptEng::InitEngine()
{
if (m_pEngine==NULL) {
m_pEngine = new QScriptEngine();
}
if (m_bDebugger && m_pDebugger==NULL) {
m_pDebugger = new QScriptEngineDebugger();
m_pDebugger->setAutoShowStandardWindow(true);
m_debugWindow = m_pDebugger->standardWindow();
m_debugWindow->setWindowModality(Qt::ApplicationModal);
m_pDebugger->attachTo(m_pEngine);
}
if (m_pEngine) {
// init the generic functions
m_pEngine->globalObject().setProperty("print", m_pEngine->newFunction(myprint, 1));
m_pEngine->globalObject().setProperty("alert", m_pEngine->newFunction(myalert, 1));
if (m_pMyWgt != NULL) {
QScriptValue MyObj = m_pEngine->newQObject((QObject*)m_pMyWgt );
m_pEngine->globalObject().setProperty("page", MyObj );
}
m_pEngine->setProcessEventsInterval(100);
}
return true;
}
void MyScriptEng::Init(MyWidget* pWgt)
{
if (m_bDebugger)//If debugger is available
{
m_pDebugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
m_pExitAction= m_pDebugger->action(QScriptEngineDebugger::ContinueAction);
}
if(m_pEngine){
QScriptValue ret = m_pEngine->evaluate(m_strContents);
if (ret.isError()) {
// reportScriptError(ret);
// todo: display error
}
}
}
void MyScriptEng::Deinit()
{
if(m_pEngine){
if(m_pDebugger && m_pDebugger->state()==QScriptEngineDebugger::RunningState)
{
m_pExitAction->trigger();//IS this enough to continue the debugger
m_debugWindow->close();
qApp->processEvents();
}
To copy to clipboard, switch view to plain text mode
Bookmarks