[PyKDE] BUG - disconnect

2002-10-28 Thread Kaleb Pederson
Disconnect doesn't seem to work as expected.

Per the Qt documentation (qobject.html#disconnect) I should be able to 
disconnect signals as follows.

I've tried various methods:

def sigDiscon(self):
self.disconnect() # Test 1
#QObject.disconnect(self,0,0,0) # Test 2 - or None,None,None
#self.disconnect(PYSIGNAL("fireAway")) # Test 3
#self.disconnect(SIGNAL("clicked()")) # Test 4
#QObject.disconnect(self,SIGNAL("clicked()")) # Test 5
#QObject.disconnect(self,SIGNAL("clicked()"),0) # Test 6 - or None
#QObject.disconnect(self,PYSIGNAL("fireAway")) # Test 7

which are all very similar to the documentation examples.  SIP can't seem to 
tell which method really should be called, and None and 0 aren't accepted as 
valid wild cards so I can't really give it the parameters that I need.

I've attached an example that demonstrates the above.

--Kaleb
#!/usr/bin/python

from qt import *
import sys

class MyDialog(QDialog):
	
	def __init__(self,parent = None,name = "MyDialog",modal=0,fl=0):
		QDialog.__init__(self,parent,name,modal,fl)

		self.setCaption("Testing")

		main_layout = QVBoxLayout(self,11,6,"main_layout")
		
		self.button1 = QPushButton(self,"button1")
		self.button1.setText(u'fire')
		
		main_layout.addWidget(self.button1)
		self.connect(self.button1,SIGNAL("clicked()"),self.fire)
		self.connect(self.button1,SIGNAL("clicked()"),self.fireAway)

		self.button2 = QPushButton(self,"button2")
		self.button2.setText(u'disconnect')
		
		main_layout.addWidget(self.button2)
		self.connect(self.button2,SIGNAL("clicked()"),self.sigDiscon)

		self.button3 = QPushButton(self,"button3")
		self.button3.setText(u'Quit')

		main_layout.addWidget(self.button3)
		self.connect(self.button3,SIGNAL("clicked()"),SLOT("accept()"))
		
	def sigDiscon(self):
		self.disconnect() # Test 1 
		#QObject.disconnect(self,0,0,0) # Test 2 - or None,None,None
		#self.disconnect(PYSIGNAL("fireAway")) # Test 3
		#self.disconnect(SIGNAL("clicked()")) # Test 4
		#QObject.disconnect(self,SIGNAL("clicked()")) # Test 5
		#QObject.disconnect(self,SIGNAL("clicked()"),0) # Test 6 - or None
		#QObject.disconnect(self,PYSIGNAL("fireAway")) # Test 7


	def fireAway(self):
		self.fire("fireAway")

	def fire(self,msg = u"Message"):
		mb = QMessageBox(self,"mb")
		mb.setCaption(u"Caption")
		mb.setText(msg)
		mb.exec_loop()
	

qapp = QApplication(sys.argv)
mw = MyDialog()
qapp.setMainWidget(mw)
mw.show()
sys.exit(mw.exec_loop())



Re: [PyKDE] BUG - disconnect

2002-11-03 Thread Phil Thompson
On Tuesday 29 October 2002 12:46 am, Kaleb Pederson wrote:
> Disconnect doesn't seem to work as expected.
>
> Per the Qt documentation (qobject.html#disconnect) I should be able to
> disconnect signals as follows.
>
> I've tried various methods:
>
> def sigDiscon(self):
> self.disconnect() # Test 1
> #QObject.disconnect(self,0,0,0) # Test 2 - or None,None,None
> #self.disconnect(PYSIGNAL("fireAway")) # Test 3
> #self.disconnect(SIGNAL("clicked()")) # Test 4
> #QObject.disconnect(self,SIGNAL("clicked()")) # Test 5
> #QObject.disconnect(self,SIGNAL("clicked()"),0) # Test 6 - or None
> #QObject.disconnect(self,PYSIGNAL("fireAway")) # Test 7
>
> which are all very similar to the documentation examples.  SIP can't seem
> to tell which method really should be called, and None and 0 aren't
> accepted as valid wild cards so I can't really give it the parameters that
> I need.

It just isn't supported. I've updated the TODO list and the documentation.

Phil

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] BUG - disconnect

2002-11-04 Thread Kaleb Pederson
On Sunday 03 November 2002 12:13 pm, Phil Thompson wrote:
> On Tuesday 29 October 2002 12:46 am, Kaleb Pederson wrote:
> > Disconnect doesn't seem to work as expected.
> >
> > 
> >
> > which are all very similar to the documentation examples.  SIP can't seem
> > to tell which method really should be called, and None and 0 aren't
> > accepted as valid wild cards so I can't really give it the parameters
> > that I need.
>
> It just isn't supported. I've updated the TODO list and the documentation.

Thanks.  Although it isn't usually necessary, it will be nice to have.  There 
is a bug in PyQt with respect to connections being removed when the 
associated object has been deleted. But I'll try to post some example code 
within the week.

Basically, if I create a parentless object and connect signals to it.  Upon 
deletion of the object, any signals that would thereafter have gone to it 
result in a sip runtime error saying the C++ object has been deleted.

--Kaleb

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] BUG - disconnect

2002-11-04 Thread Kaleb Pederson
> Thanks.  Although it isn't usually necessary, it will be nice to have. 
> There is a bug in PyQt with respect to connections being removed when the
> associated object has been deleted. But I'll try to post some example code
> within the week.
>
> Basically, if I create a parentless object and connect signals to it.  Upon
> deletion of the object, any signals that would thereafter have gone to it
> result in a sip runtime error saying the C++ object has been deleted.

Okay, I modified my previous example to show what is happening.  I highly 
doubt this is my fault, but if it is, I'm sure you'll correct me ;)

I ran it through gdb to see where it was dieing... the last few items in the 
backtrace gave me the following:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 12956)]
0x4141e740 in lazyMethods_QObject () from 
/usr/lib/python2.2/site-packages/libqtcmodule.so
(gdb) bt
#0  0x4141e740 in lazyMethods_QObject () from 
/usr/lib/python2.2/site-packages/libqtcmodule.so
#1  0x0202 in ?? ()
#2  0x4001f05c in parsePass2 () from 
/usr/lib/python2.2/site-packages/libsip.so
#3  0x4001e89f in sipParseArgs () from 
/usr/lib/python2.2/site-packages/libsip.so
#4  0x413ace9f in sipDo_QWidget_close () from 
/usr/lib/python2.2/site-packages/libqtcmodule.so
#5  0x080d86fd in PyCFunction_Call ()
#6  0x080b62be in PyObject_Call ()
#7  0x0807f350 in PyEval_CallObjectWithKeywords ()
...

Note. If I comment out line 64 then the program works fine and won't segfault.

To reproduce what I did, leave line 64 in and then launch the program.  Hit 
"Launch" as many times as you like.  Now hit "Fire".  All the "child" 
(although parentless) objects get closed/deleted.  Now hit "Fire" a second 
time.  Boom!

Another way to reproduce it is to create some child objects by hitting launch.  
Now close the child objects so they get deleted appropriately.  Once all 
child objects are closed, hit "Fire".

Well, please let me know what you find.  Even if there is just a work around, 
it would be nice to know.

--Kaleb

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] BUG - disconnect

2002-11-04 Thread Kaleb Pederson
On Monday 04 November 2002 05:59 am, Kaleb Pederson wrote:
> Thanks.  Although it isn't usually necessary, it will be nice to have. 
> There is a bug in PyQt with respect to connections being removed when the
> associated object has been deleted. But I'll try to post some example code
> within the week.
>
> Basically, if I create a parentless object and connect signals to it.  Upon
> deletion of the object, any signals that would thereafter have gone to it
> result in a sip runtime error saying the C++ object has been deleted.

I just posted a message on the list and forgot to include an attachment.  Here 
it is.

--Kaleb


#!/usr/bin/python

from qt import *
import sys

class MyDialog(QDialog):
	
	def __init__(self,id = 0,parent = None,name = "MyDialog",modal=0,fl=0):
		QDialog.__init__(self,parent,name,modal,fl)

		self.id = id
		self.count = 0
		self.keep_ref = {}

		self.setCaption("Testing" + str(id))

		main_layout = QVBoxLayout(self,11,6,"main_layout")
		
		self.button1 = QPushButton(self,"button1")
		self.button1.setText(u'&Launch')
		
		main_layout.addWidget(self.button1)
		self.connect(self.button1,SIGNAL("clicked()"),self.launch)

		self.button2 = QPushButton(self,"button2")
		self.button2.setText(u'&Fire')

		main_layout.addWidget(self.button2)
		self.connect(self.button2,SIGNAL("clicked()"),self.fire)
		
		self.button3 = QPushButton(self,"button3")
		self.button3.setText(u'&Quit')

		main_layout.addWidget(self.button3)
		self.connect(self.button3,SIGNAL("clicked()"),self,SLOT("accept()"))
	
	def caught(self):
		print "dlg %i caught 'fire()' signal" % self.id
	
	def fire(self):
		self.emit(PYSIGNAL("fire()"), () )
	
	def closeEvent(self,event):
		print "dlg %i is closing" % self.id
		self.emit(PYSIGNAL("closing(id)"),(self.id,))
		event.accept()
	
	def accept(self):
		self.emit(PYSIGNAL("closing(id)"),(self.id,))
		QDialog.accept(self)
	
	def cleanup(self,id):
		print "cleaning up id %i" % id
		if id in self.keep_ref.keys():
			del self.keep_ref[id]
		print "references remaining:",self.keep_ref
	
	def launch(self):
		# keep a reference so it doesn't get destroyed
		dlg = MyDialog(self.count) # no parent
		self.connect(self,PYSIGNAL("fire()"),dlg.caught)
		
		# it works fine unless this signal is connected
		self.connect(self,PYSIGNAL("fire()"),dlg, SLOT("close()"))
		
		self.connect(dlg,PYSIGNAL("closing(id)"),self.cleanup)
		self.keep_ref[self.count] = dlg
		self.count += 1
		dlg.show()

qapp = QApplication(sys.argv)
mw = MyDialog()
qapp.setMainWidget(mw)
mw.show()
sys.exit(mw.exec_loop())



Re: [PyKDE] BUG - disconnect

2002-11-06 Thread Phil Thompson
On Monday 04 November 2002 1:59 pm, Kaleb Pederson wrote:
> On Sunday 03 November 2002 12:13 pm, Phil Thompson wrote:
> > On Tuesday 29 October 2002 12:46 am, Kaleb Pederson wrote:
> > > Disconnect doesn't seem to work as expected.
> > >
> > > 
> > >
> > > which are all very similar to the documentation examples.  SIP can't
> > > seem to tell which method really should be called, and None and 0
> > > aren't accepted as valid wild cards so I can't really give it the
> > > parameters that I need.
> >
> > It just isn't supported. I've updated the TODO list and the
> > documentation.
>
> Thanks.  Although it isn't usually necessary, it will be nice to have. 
> There is a bug in PyQt with respect to connections being removed when the
> associated object has been deleted. But I'll try to post some example code
> within the week.
>
> Basically, if I create a parentless object and connect signals to it.  Upon
> deletion of the object, any signals that would thereafter have gone to it
> result in a sip runtime error saying the C++ object has been deleted.

This should now be fixed in tonight's SIP snapshot. You should re-build PyQt 
with the new version.

Phil

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] BUG - disconnect

2002-11-06 Thread Kaleb Pederson
On Wednesday 06 November 2002 04:00 pm, Phil Thompson wrote:
> > 
> >
> > Thanks.  Although it isn't usually necessary, it will be nice to have.
> > There is a bug in PyQt with respect to connections being removed when the
> > associated object has been deleted. But I'll try to post some example
> > code within the week.
> >
> > Basically, if I create a parentless object and connect signals to it. 
> > Upon deletion of the object, any signals that would thereafter have gone
> > to it result in a sip runtime error saying the C++ object has been
> > deleted.
>
> This should now be fixed in tonight's SIP snapshot. You should re-build
> PyQt with the new version.
>
> Phil

Thank you.  It will help a lot.

--Kaleb

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde