Discussion:
signal twice emit
Csaba Toth
2010-06-29 13:06:31 UTC
Permalink
Hi,

i have a problem with recent PyQt versions, sometimes a signal (what i
saw was with button click signal) emitted twice.

for example i use this:

def p(self, clicked=False):
print('emitted')
self.connect(self.btn_save, QtCore.SIGNAL("clicked(bool)"), self.p)

and if i press the button it wrotes twice the 'emitted' to console.
What i make wrong?

thanks in advance,
Csaba
Nick Gaens
2010-06-29 13:38:50 UTC
Permalink
Try this way of connecting:

self.btn_save.clicked.connect(self.p)
Post by Csaba Toth
Hi,
i have a problem with recent PyQt versions, sometimes a signal (what i
saw was with button click signal) emitted twice.
print('emitted')
self.connect(self.btn_save, QtCore.SIGNAL("clicked(bool)"), self.p)
and if i press the button it wrotes twice the 'emitted' to console.
What i make wrong?
thanks in advance,
Csaba
_______________________________________________
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
Nick Gaens
Csaba Toth
2010-06-29 17:42:37 UTC
Permalink
Thanks for the advices, but this happens just with the most recent
versions of PyQt, i think it started to appear after i upgradeed to 4.7.
I used all versions from the 4.7 era, don't remember if it happened at
the early versions, but with the most recent version it does.
I use PyQt and QT for 4 year long from now, never seen any defect like
this. This program was developed 3 year ago, i don't think the solution
will be to change the connection methods, or to modify anything in the
code of the program. This is like plug into our heads in the sand
instead of to figure out what is the problem with PyQt.

Some day ago i compiled Qt 4.6.3 and SIP/PyQt-latest, but not with
MinGW, but with VC2008. Result was the same, so I think the problem will
be with PyQt/SIP/QT somewhere.
Tried to make a sample app, but no luck, sometimes it happens sometimes
not. For example here 20 computer runs this program, about the 20% of
the clients told me to have this happened per day, and 1 to 3 times per
day, it's full random. But sometimes a simple test app what i wrote do
it constantly.

regards,
Csaba
Post by Nick Gaens
self.btn_save.clicked.connect(self.p)
Hi,
i have a problem with recent PyQt versions, sometimes a signal (what i
saw was with button click signal) emitted twice.
print('emitted')
self.connect(self.btn_save, QtCore.SIGNAL("clicked(bool)"), self.p)
and if i press the button it wrotes twice the 'emitted' to console.
What i make wrong?
thanks in advance,
Csaba
_______________________________________________
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
Nick Gaens
_______________________________________________
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
_______________________________________________
PyQt mailing list ***@riverbankcomputing.com
http://www.rive
David Boddie
2010-06-29 19:14:37 UTC
Permalink
Post by Csaba Toth
Thanks for the advices, but this happens just with the most recent
versions of PyQt, i think it started to appear after i upgradeed to 4.7.
I used all versions from the 4.7 era, don't remember if it happened at
the early versions, but with the most recent version it does.
It would be interesting to try it with an earlier version if possible, though
I could understand if that's not possible.
Post by Csaba Toth
print('emitted')
self.connect(self.btn_save, QtCore.SIGNAL("clicked(bool)"), self.p)
Initially, I thought this could be a problem with both the clicked() and the
clicked(bool) signals being connected to the slot, but that shouldn't happen
if the signature is used like this. You could check to see if the behavior
changes by decorating p() like this:

@pyqtSlot("bool")
def p(self, clicked=False):
print('emitted')

It's difficult to know exactly what could cause this without some more
context. I've seen code that uses signal-slot auto-connection and also
includes connect() calls, resulting in double connections.

David
--
David Boddie
Senior Technical Writer
Nokia, Qt
Csaba Toth
2010-06-30 19:28:08 UTC
Permalink
Hi!
Post by David Boddie
Post by Csaba Toth
print('emitted')
self.connect(self.btn_save, QtCore.SIGNAL("clicked(bool)"), self.p)
Initially, I thought this could be a problem with both the clicked() and the
clicked(bool) signals being connected to the slot, but that shouldn't happen
if the signature is used like this. You could check to see if the behavior
@pyqtSlot("bool")
print('emitted')
It's difficult to know exactly what could cause this without some more
context. I've seen code that uses signal-slot auto-connection and also
includes connect() calls, resulting in double connections.
There is no double connection, checked it manually with a print next to
the connect.

And i tried this decorator today, from the 20 people 3 people dropped an
email to me that they had this problem showed up today. The first did
after 3 work hour with the program, and after a few double invokioning
it started to work normally.
(this is a simple data store program. There is one dialog with a lot
check box and an ID lineEdit field. If they click on the save button it
first store the datas in a postgres table, and than clears the form. if
the lineedit is empty they had a warning pops up. the error looks like a
worker fills up the form, click on the save button, than the warning
shows up they haven't filled up the ID lineedit, but they did. This
happens because at the first invokion of the click event it save than
clear the form, and at the second run the ID lineedit truly empty.
during the day they didn't touch the progrma, they don't exit, just fill
up the form and save.)

looks like a memory leak for me :(
Post by David Boddie
It would be interesting to try it with an earlier version if possible, though
I could understand if that's not possible.
Yes, i will try this tomorrow, first will go back to PyQt 4.6.* version.

I have a lot installers saved, becase sadly from the website no old
versions downloadable. :(

thanks for helping, let see what will happen tomorrow with older version!

regards,
Csaba
Post by David Boddie
David
_______________________________________________
PyQt mailing list ***@riverbankcomputing.com
http://www.
Csaba Toth
2010-07-01 17:50:14 UTC
Permalink
Hi!

last evening recompiled the program with PyQt 4.6.2 (it has Qt 4.5.3),
and today the problem gone, no one complained.

Phil, what you think, is it a good idea to compile PyQt 4.6.2+Qt 4.6.3,
or PyQt 4.7.3+Qt 4.5.3? Or have a better idea?

thanks in advance,
Csaba
Post by David Boddie
Hi!
Post by David Boddie
Post by Csaba Toth
print('emitted')
self.connect(self.btn_save, QtCore.SIGNAL("clicked(bool)"), self.p)
Initially, I thought this could be a problem with both the clicked()
and the
Post by David Boddie
clicked(bool) signals being connected to the slot, but that shouldn't
happen
Post by David Boddie
if the signature is used like this. You could check to see if the behavior
@pyqtSlot("bool")
print('emitted')
It's difficult to know exactly what could cause this without some more
context. I've seen code that uses signal-slot auto-connection and also
includes connect() calls, resulting in double connections.
There is no double connection, checked it manually with a print next to
the connect.
And i tried this decorator today, from the 20 people 3 people dropped an
email to me that they had this problem showed up today. The first did
after 3 work hour with the program, and after a few double invokioning
it started to work normally.
(this is a simple data store program. There is one dialog with a lot
check box and an ID lineEdit field. If they click on the save button it
first store the datas in a postgres table, and than clears the form. if
the lineedit is empty they had a warning pops up. the error looks like a
worker fills up the form, click on the save button, than the warning
shows up they haven't filled up the ID lineedit, but they did. This
happens because at the first invokion of the click event it save than
clear the form, and at the second run the ID lineedit truly empty.
during the day they didn't touch the progrma, they don't exit, just fill
up the form and save.)
looks like a memory leak for me :(
Post by David Boddie
It would be interesting to try it with an earlier version if possible, though
I could understand if that's not possible.
Yes, i will try this tomorrow, first will go back to PyQt 4.6.* version.
I have a lot installers saved, becase sadly from the website no old
versions downloadable. :(
thanks for helping, let see what will happen tomorrow with older version!
regards,
Csaba
Post by David Boddie
David
_______________________________________________
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
_______________________________________________
PyQt mailing list ***@riverbankcomputing.com
Phil Thompson
2010-07-01 21:28:37 UTC
Permalink
On Thu, 01 Jul 2010 19:50:14 +0200, Csaba Toth
Post by Csaba Toth
Hi!
last evening recompiled the program with PyQt 4.6.2 (it has Qt 4.5.3),
and today the problem gone, no one complained.
Phil, what you think, is it a good idea to compile PyQt 4.6.2+Qt 4.6.3,
or PyQt 4.7.3+Qt 4.5.3? Or have a better idea?
I need a test case so that I can reproduce the problem.

Phil

Loading...