[PyQt] Bye bye segmentation fault

Cyril Giraudon cyril.giraudon at free.fr
Mon Sep 20 12:28:56 BST 2010


  Oh you are right, sorry

I didn't refactor the "quit_action" part :

dialog.connect(quit_action, SIGNAL("triggered()"), app, SLOT("quit()"));
quit_action.connect(quit_action, SIGNAL("triggered()"), app, 
SLOT("quit()"));
-> Segmentation Fault

quit_action.triggered.connect(quit)
-> fixes the problem

Even if I don't understand where the "quit" function come from lol.

Thanks a lot !!!

Cyril.



Le 20/09/2010 13:06, Vincent Vande Vyvre a écrit :
> Le 20/09/10 11:42, Cyril Giraudon a écrit :
>> Modifications in the code don't make things nicer :-( :
>>
>> Sorry for not reporting the system characteristics :
>>
>> (sandbox)cyril at CGN-L: pyqt$ python example.py
>> Platform :  Linux-2.6.32-24-generic-i686-with-Ubuntu-10.04-lucid
>> Machine :  i686
>> Qt version :  4.6.2
>> PyQt version :  4.7.2
>> Just after exec_ ...
>> Erreur de segmentation
>>
>> I note the same behaviour on x86_64-with-Ubuntu-10.04-lucid
>>
>> Regards,
>>
>> Cyril.
>>
>>
>>
>> Le 20/09/2010 11:04, Vincent Vande Vyvre a écrit :
>>> Le 20/09/10 10:07, Cyril Giraudon a écrit :
>>>>  Hello,
>>>>
>>>> I am a PyQt newbye and I wanted to do some tests with QToolBar in a 
>>>> QDialog (Seems multiple QMainWindow use is not recommanded in a 
>>>> QApplication), so I started coding a simple example (reported below).
>>>>
>>>> The code seems correct but it terminates with a segmentation fault 
>>>> when the QUIT button is pressed :
>>>>
>>>> """""""""""""""""""""""""""""""""""""
>>>> (sandbox)cyril at CGN-L: pyqt$ python example.py
>>>> Qt version :  4.6.2
>>>> PyQt version :  4.7.2
>>>> Erreur de segmentation
>>>> """""""""""""""""""""""""""""""""""""
>>>>
>>>> I don't understand what happens.
>>>> Is there any explanation ?
>>>>
>>>> Thanks a lot,
>>>>
>>>> Cyril.
>>>>
>>>>
>>>> """""""""""""""""""""""""""""""""
>>>> example.py source code
>>>> """""""""""""""""""""""""""""""""
>>>> # -*- coding: utf8 -*-
>>>>
>>>> import sys
>>>>
>>>> from PyQt4.QtCore import SIGNAL, SLOT, QT_VERSION_STR, 
>>>> PYQT_VERSION_STR
>>>> from PyQt4.QtGui import (QApplication, QDialog, QVBoxLayout,
>>>>                          QToolBar, QAction, QLabel)
>>>>
>>>> if __name__=='__main__':
>>>>     print "Qt version : ", QT_VERSION_STR
>>>>     print "PyQt version : ", PYQT_VERSION_STR
>>>>
>>>>     app = QApplication(sys.argv)
>>>>
>>>>     dialog = QDialog()
>>>>     dialog.setWindowTitle(u"Bye bye")
>>>>
>>>>     layout = QVBoxLayout(dialog)
>>>>
>>>>     toolbar = QToolBar()
>>>>
>>>>     label = QLabel("Hello World!")
>>>>     def say_bye():
>>>>         label.setText("Bye Bye")
>>>>     bye_action = QAction("Bye bye", dialog, triggered=say_bye)
>>>>     toolbar.addAction(bye_action)
>>>>
>>>>     quit_action = QAction("Quit", dialog)
>>>>     dialog.connect(quit_action, SIGNAL("triggered()"),
>>>>                    app, SLOT("quit()"));
>>>>     toolbar.addAction(quit_action)
>>>>
>>>>     layout.addWidget(toolbar)
>>>>     layout.addWidget(label)
>>>>
>>>>     dialog.show()
>>>>     app.exec_()
>>>> """""""""""""""""""""""""""""""""""""""""
>>>> _______________________________________________
>>>> PyQt mailing list PyQt at riverbankcomputing.com
>>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>>
>>> Salut,
>>>
>>> Change these lines:
>>>
>>>     bye_action = QAction("Bye bye", dialog)
>>>     bye_action.triggered.connect(say_bye)
>>>     toolbar.addAction(bye_action)
>>>
>>>     quit_action = QAction("Quit", dialog)
>>>     quit_action.triggered.connect(quit)
>>>     toolbar.addAction(quit_action)
>>>
>>> and this one:
>>>
>>>     sys.exit(app.exec_())
>>>
>>> Cheers
>>>
>>> -- 
>>> Vincent V.V.
>>> Oqapy <https://launchpad.net/oqapy>
>>>
>>>
>>> _______________________________________________
>>> PyQt mailing listPyQt at riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>>
>> _______________________________________________
>> PyQt mailing listPyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> It's strange, After the changes I do not have any more errors
>
> I'm under Lucid 32b
>
> vincent at tiemoko:~/Bureau$ python bye.py
> Qt version :  4.6.2
> PyQt version :  4.7.2
> vincent at tiemoko:~/Bureau$
>
> -- 
> Vincent V.V.
> Oqapy <https://launchpad.net/oqapy>
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100920/6cfaf8f8/attachment.html>


More information about the PyQt mailing list