Hello.
I have compiled Qt for 64-bit architecture under windows and all works fine except QtScript. The following simple code, working perfectly with 32-bit Qt for windows installed from qtsoftware.com, crashes if compiled with 64-bit Qt . Maybe it's an error in my code? Or Qt is not compatible with 64-bit? Or it is a bug and i need to submit it somehow?
Qt console project.
main.h
#pragma once
#include <QObject>
#include <QScriptEngine>
{
Q_OBJECT;
public slots: void Test();
private: QScriptEngine m_oEngine;
};
{
Q_OBJECT;
signals: void ScriptTest();
};
#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* );
};
To copy to clipboard, switch view to plain text mode
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 ++ ) "
"{ \"a\" + a[ 0 ][ 0 ]; } } }";
m_oEngine.evaluate( sScript );
QScriptValue oFnStart = m_oEngine.evaluate( "OnStart" );
oFnStart.call();
}
int main(int argc, char *argv[])
{
scriptThread.start();
Script script;
script.moveToThread( & scriptThread );
App app;
script.connect( & app, SIGNAL( ScriptTest() ), SLOT( Test() ) );
app.startTimer( 50 );
return a.exec();
}
#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 ++ ) "
"{ \"a\" + a[ 0 ][ 0 ]; } } }";
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();
}
To copy to clipboard, switch view to plain text mode
Bookmarks