Details
Description
Following code works perfectly if compiled with Qt 4.6.0 32-bit from QT window installer.
If Qt is compiled as 64-bit using Microsoft Windows SDK (http://tinyurl.com/yjmzhno) code crashes. I have checked both with 4.6.0 sources from www.qtsoftware.com and latest Git snapshot. Code is console Qt application, crashes both in debug and release with access violation:
main.h
#pragma once
#include <QObject>
#include <QScriptEngine>
class Script : public QObject
{
Q_OBJECT;
public slots: void Test();
private: QScriptEngine m_oEngine;
};
class App : public QObject
{
Q_OBJECT;
signals: void ScriptTest();
protected: void timerEvent( QTimerEvent* );
};
main.cpp
#include <QtCore/QCoreApplication>
#include <QThread>
#include "main.h"
void Script::Test()
{
QString sScript = "function OnStart() { var a = [ [ 0 ] ]; "
"for( var i = 0; i < 3; i ++ ) { for( var j = 0; j < 100; j ++ ) "
"
} }";
m_oEngine.evaluate( sScript );
QScriptValue oFnStart = m_oEngine.evaluate( "OnStart" );
oFnStart.call();
}
void App::timerEvent( QTimerEvent* )
{ ScriptTest(); }int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QThread scriptThread;
scriptThread.start();
Script script;
script.moveToThread( & scriptThread );
App app;
script.connect( & app, SIGNAL( ScriptTest() ), SLOT( Test() ) );
app.startTimer( 50 );
return a.exec();
}