Hi!

I am making a front-end to ffmpeg with pyqt and I am stuck in a
segmentation fault I can't understand. I have written a little
dialogbox just to show the problem. I have already found a workaround,
commented out in the code, but I would like to know where is the
problem.

I am sending the pyuic-generated file in attachment, as well as ui file.

I am working in a debian/lenny system, with py 2.4 and 2.5.

cbox.py
=======

#!/usr/bin/python2.5
# -*- coding: utf-8 -*-

from PyQt4 import QtCore, QtGui
from comboboxsegfault import Ui_Dialog
import sys

class Aux:
    pass
    
class Combobox(QtGui.QDialog):
    def __init__(self):
        QtGui.QDialog.__init__(self)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
                        
        self.connect(self.ui.comboBox, QtCore.SIGNAL("activated(QString)"),
                     self.save)
        def save(self, qstring):
            # Here it works:
            #Aux.mystring = unicode(qstring)
            Aux.mystring = qstring
                                         
def main(args):
    app = QtGui.QApplication(args)
    win = Combobox()
    win.show()
    app.exec_()

    print type(Aux.mystring)
    # If uncommented segfaults
    # mystring = unicode(Aux.mystring)
    print ("The same" if Aux.mystring==Aux.mystring2 else "Different")
    print Aux.compare
    # segfault
    print Aux.mystring
def compare(args):
    st = QtCore.QString("Second")
    Aux.compare = st
                        
if __name__=='__main__':
    compare(sys.argv)
    main(sys.argv)

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'comboboxsegfault.ui'
#
# Created: Fri Nov 30 09:43:39 2007
#      by: PyQt4 UI code generator 4.3
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,400,300).size()).expandedTo(Dialog.minimumSizeHint()))

        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(30,240,341,32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.NoButton|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")

        self.comboBox = QtGui.QComboBox(Dialog)
        self.comboBox.setGeometry(QtCore.QRect(60,30,231,31))
        self.comboBox.setObjectName("comboBox")

        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),Dialog.accept)
        QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
        self.comboBox.addItem(QtGui.QApplication.translate("Dialog", "First", None, QtGui.QApplication.UnicodeUTF8))
        self.comboBox.addItem(QtGui.QApplication.translate("Dialog", "Second", None, QtGui.QApplication.UnicodeUTF8))

<ui version="4.0" >
 <class>Dialog</class>
 <widget class="QDialog" name="Dialog" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>Dialog</string>
  </property>
  <widget class="QDialogButtonBox" name="buttonBox" >
   <property name="geometry" >
    <rect>
     <x>30</x>
     <y>240</y>
     <width>341</width>
     <height>32</height>
    </rect>
   </property>
   <property name="orientation" >
    <enum>Qt::Horizontal</enum>
   </property>
   <property name="standardButtons" >
    
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
   </property>
  </widget>
  <widget class="QComboBox" name="comboBox" >
   <property name="geometry" >
    <rect>
     <x>60</x>
     <y>30</y>
     <width>231</width>
     <height>31</height>
    </rect>
   </property>
   <item>
    <property name="text" >
     <string>First</string>
    </property>
   </item>
   <item>
    <property name="text" >
     <string>Second</string>
    </property>
   </item>
  </widget>
 </widget>
 <resources/>
 <connections>
  <connection>
   <sender>buttonBox</sender>
   <signal>accepted()</signal>
   <receiver>Dialog</receiver>
   <slot>accept()</slot>
   <hints>
    <hint type="sourcelabel" >
     <x>248</x>
     <y>254</y>
    </hint>
    <hint type="destinationlabel" >
     <x>157</x>
     <y>274</y>
    </hint>
   </hints>
  </connection>
  <connection>
   <sender>buttonBox</sender>
   <signal>rejected()</signal>
   <receiver>Dialog</receiver>
   <slot>reject()</slot>
   <hints>
    <hint type="sourcelabel" >
     <x>316</x>
     <y>260</y>
    </hint>
    <hint type="destinationlabel" >
     <x>286</x>
     <y>274</y>
    </hint>
   </hints>
  </connection>
 </connections>
</ui>
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to