PDA

View Full Version : Qt 4.7 limit on number of signals?



rghosh
9th February 2011, 08:23
I've been trying to migrate an application from Qt 4.6.2 to 4.7.0, and had a problem in 4.7 where I can only successfully connect a certain number of signals.

I've written a simple test program in Python using the PySide bindings that demonstrates the problem. In the test program, on each timer timeout, a new signal is defined and connected to a callback, and all signals defined thus far are emitted. The source-code for this small test is in attached test.py and also listed at the bottom of this post.

Using Qt 4.6.2, this works as I expected, with the output in attached qt4.6.2output.txt


$ python test.py
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17


But using Qt 4.7.0, the callback is not called for new signals after a limit has been reached: in the example the limit was 11. The output is in attached 4.7.0output.txt.


$ python test.py
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11

The system with Qt 4.6.2 installed runs Ubuntu 10.04

$ cat /proc/version
Linux version 2.6.32-26-generic (buildd@rothera) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #48-Ubuntu SMP Wed Nov 24 09:00:03 UTC 2010
$ apt-cache show libqtcore4
...
Version: 4:4.6.2-0ubuntu5.1

The system with Qt 4.7.0 installed runs Ubuntu 10.10

$ cat /proc/version
Linux version 2.6.35-24-virtual (buildd@vernadsky) (gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) ) #42-Ubuntu SMP Thu Dec 2 05:01:52 UTC 2010
$ apt-cache show libqtcore4
...
Version: 4:4.7.0-0ubuntu4

Here is the source code for the example:


import sys
from PySide import QtCore, QtGui

class Window(QtGui.QMainWindow):

def __init__(self):
super(Window, self).__init__()
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.onTimeout)
self.n = 0

self.timer.start(1000)

@QtCore.Slot()
def onTimeout(self):

exec("Window.sig%d = QtCore.Signal(object, object)" % self.n)
eval("self.sig%d" % self.n).connect(self.onSignalN)

for i in xrange(self.n+1):
eval("self.sig%d[object, object]" % i).emit( i,self )

self.n += 1
print ""

@QtCore.Slot(object, object)
def onSignalN(self, o1, o2):
print o1,

app = QtGui.QApplication(sys.argv)

win = Window()

win.resize(320, 240)
win.setWindowTitle("Hello, World!")
win.show()

sys.exit(app.exec_())

Ranen

wysota
9th February 2011, 09:29
If such a limitation exists, it is implied by PySide and not Qt. This code works properly in Qt 4.7:

#include <QtCore>

class Object : public QObject {
Q_OBJECT
public:
Object() {}
signals:
void sig1();
void sig2();
void sig3();
void sig4();
void sig5();
void sig6();
void sig7();
void sig8();
void sig9();
void sig10();
void sig11();
void sig12();
void sig13();
void sig14();
void sig15();
void sig16();
void sig17();
void sig18();
void sig19();
void sig20();
private slots:
void onsig1() { qDebug() << Q_FUNC_INFO; }
void onsig2() { qDebug() << Q_FUNC_INFO; }
void onsig3() { qDebug() << Q_FUNC_INFO; }
void onsig4() { qDebug() << Q_FUNC_INFO; }
void onsig5() { qDebug() << Q_FUNC_INFO; }
void onsig6() { qDebug() << Q_FUNC_INFO; }
void onsig7() { qDebug() << Q_FUNC_INFO; }
void onsig8() { qDebug() << Q_FUNC_INFO; }
void onsig9() { qDebug() << Q_FUNC_INFO; }
void onsig10() { qDebug() << Q_FUNC_INFO; }
void onsig11() { qDebug() << Q_FUNC_INFO; }
void onsig12() { qDebug() << Q_FUNC_INFO; }
void onsig13() { qDebug() << Q_FUNC_INFO; }
void onsig14() { qDebug() << Q_FUNC_INFO; }
void onsig15() { qDebug() << Q_FUNC_INFO; }
void onsig16() { qDebug() << Q_FUNC_INFO; }
void onsig17() { qDebug() << Q_FUNC_INFO; }
void onsig18() { qDebug() << Q_FUNC_INFO; }
void onsig19() { qDebug() << Q_FUNC_INFO; }
void onsig20() { qDebug() << Q_FUNC_INFO; }
private:
friend int main(int, char**);
};

#include "main.moc"

int main(int argc, char **argv){
Object o;
for(int i=1;i<=20;++i){
QObject::connect(&o, qPrintable(QString("2sig%1()").arg(i)), &o, qPrintable(QString("1onsig%1()").arg(i)));
}
emit o.sig1();
emit o.sig2();
emit o.sig3();
emit o.sig4();
emit o.sig5();
emit o.sig6();
emit o.sig7();
emit o.sig8();
emit o.sig9();
emit o.sig10();
emit o.sig11();
emit o.sig12();
emit o.sig13();
emit o.sig14();
emit o.sig15();
emit o.sig16();
emit o.sig17();
emit o.sig18();
emit o.sig19();
emit o.sig20();
return 0;
}

witht the result of:

void Object::onsig1()
void Object::onsig2()
void Object::onsig3()
void Object::onsig4()
void Object::onsig5()
void Object::onsig6()
void Object::onsig7()
void Object::onsig8()
void Object::onsig9()
void Object::onsig10()
void Object::onsig11()
void Object::onsig12()
void Object::onsig13()
void Object::onsig14()
void Object::onsig15()
void Object::onsig16()
void Object::onsig17()
void Object::onsig18()
void Object::onsig19()
void Object::onsig20()

rghosh
9th February 2011, 10:32
Thank you. I have forwarded my question to the pyside mailing list. (The alternative python bindings, PyQt, didn't have this problem)