You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

ptkdb

Beginner

  • "ptkdb" started this thread

Posts: 2

Location: Massachusetts, USA

Occupation: Consultant

  • Send private message

1

Wednesday, March 19th 2008, 8:23pm

Qt 4.3.2 QtScript newQObject Producing Bad Objects

Linux zazulak 2.6.22-14-generic #1 SMP Fri Feb 1 04:59:50 UTC 2008 i686 GNU/Linux
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)


The QObject produced in the attached code should contain 3 signals(signal1, signal2 and signal3). However, when we inspect the object from the script side(via 'call') we are missing the signal1 signal and have a duplicate signal3. In addition, the object seems to have it's properties change between 'call' invocations where we're not expecting any changes.

This problem seems to be fixed in the Qt 4.4beta1 release, but is there a Qt4.3.X version where this is corrected, or is there another workaround?

QT_VERSION => 0x40302
##
## Setting object
##
objectName => function
destroyed(QObject*) => function
deleteLater() => function
signal2(int) => function
slot1() => function
deleteLater() => function
signal2(int) => function
slot1() => function
##
## Checking object
##
objectName => function
destroyed() => function
signal3(QString) => function
deleteLater() => function
signal2(int) => function
slot1() => function
destroyed() => function
signal3(QString) => function
ptkdb has attached the following files:

2

Thursday, March 20th 2008, 3:48pm

RE: Qt 4.3.2 QtScript newQObject Producing Bad Objects

Removed from script " + typeof TestObject[property]" and got result.

Quoted

QT_VERSION => 0x40303
##
## Setting
##
objectName =>
destroyed(QObject*) =>
destroyed() =>
deleteLater() =>
signal1(bool) =>
signal2(int) =>
signal3(QString) =>
slot1() =>
##
## Checking
##
objectName =>
destroyed(QObject*) =>
destroyed() =>
deleteLater() =>
signal1(bool) =>
signal2(int) =>
signal3(QString) =>
slot1() =>

Looks like accessing object's properties in script like "TestObject[property]" in enumeration (for (a in b) {b[a];}) is broken? Though added "obj['slot1()']();" here and there in SetObject script function -slot is called and nothing is changed. Also instead "TestObject[property]" added "TestObject['slot1()']" - nothing strange happens.
Yet another experiment - pushed property string to array then used array:

Quoted


"function SetObject(obj) {\n"
" var property, arr, i ;\n"
"arr = new Array();"
"\n"
" TestObject = obj ;\n"
"\n"
" print(\"##\") ;"
" print(\"## Setting\") ;"
" print(\"##\") ;"
" for( property in obj ) \n"
" arr.push(new String(property));\n"
"for(i = 0; i < arr.length; i++) print(arr + ' => ' + obj[arr[i]]);"
" \n"

"}\n"
"\n"

Good? Hm. Don't know.
Fighting fire with fire.
Three can keep a secret if two of them are dead.

ptkdb

Beginner

  • "ptkdb" started this thread

Posts: 2

Location: Massachusetts, USA

Occupation: Consultant

  • Send private message

3

Thursday, March 20th 2008, 5:26pm

Thanks That Could Help

The intent has been to have a collection of QObjects that will have their signals automatically connected to QScript functions/methods based on a naming convention. At present we check to see if each property is typeof "function" then assess whether it meets the naming criteria. If we reverse that, and check the name first before testing typeof "function", perhaps the QObject's property list won't be broken.

This problem appears to be fixed in Qt4.4beta1