[PyQt] inevitable crash on PyQt4 Windows7-32bit, potential memory leak

胡钟晟 fdhzs2010 at hotmail.com
Sat Apr 26 11:22:40 BST 2014


hi all,
    my ui is as simple as possible, only 5 labels+5 slidebars. my point is easy: use sticks on my gamepad to control all five bars to move to the proper values.(this move may be fast to human but it should be resaonably slow for computer) and it goes on working in a few minutes then the window crashes. a visual C++ promt pops out and says "runtime error! pythonw.exe has requested the runtime to terminate it in an unusual way".

   and then, i notice that pythonw.exe ask for a few pages of memory every move and the memory doesn't go down. i am afraid there should be some bugs here.

the code generated by Qt designer is following:
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'simpleui.ui'
#
# Created: Sat Apr 26 17:13:03 2014
#      by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(675, 421)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.gridLayout_3 = QtGui.QGridLayout()
        self.gridLayout_3.setMargin(10)
        self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.gridLayout_3.addItem(spacerItem, 1, 0, 5, 1)
        self.label_10 = QtGui.QLabel(self.centralwidget)
        self.label_10.setObjectName(_fromUtf8("label_10"))
        self.gridLayout_3.addWidget(self.label_10, 4, 1, 1, 1)
        self.lySlider = QtGui.QSlider(self.centralwidget)
        self.lySlider.setEnabled(False)
        self.lySlider.setMinimum(900)
        self.lySlider.setMaximum(2100)
        self.lySlider.setOrientation(QtCore.Qt.Horizontal)
        self.lySlider.setObjectName(_fromUtf8("lySlider"))
        self.gridLayout_3.addWidget(self.lySlider, 2, 3, 1, 1)
        self.label_9 = QtGui.QLabel(self.centralwidget)
        self.label_9.setObjectName(_fromUtf8("label_9"))
        self.gridLayout_3.addWidget(self.label_9, 3, 1, 1, 1)
        self.label_7 = QtGui.QLabel(self.centralwidget)
        self.label_7.setObjectName(_fromUtf8("label_7"))
        self.gridLayout_3.addWidget(self.label_7, 1, 1, 1, 1)
        self.rySlider = QtGui.QSlider(self.centralwidget)
        self.rySlider.setEnabled(False)
        self.rySlider.setMinimum(900)
        self.rySlider.setMaximum(2100)
        self.rySlider.setOrientation(QtCore.Qt.Horizontal)
        self.rySlider.setObjectName(_fromUtf8("rySlider"))
        self.gridLayout_3.addWidget(self.rySlider, 4, 3, 1, 1)
        self.label_11 = QtGui.QLabel(self.centralwidget)
        self.label_11.setObjectName(_fromUtf8("label_11"))
        self.gridLayout_3.addWidget(self.label_11, 5, 1, 1, 1)
        self.rxSlider = QtGui.QSlider(self.centralwidget)
        self.rxSlider.setEnabled(False)
        self.rxSlider.setMinimum(900)
        self.rxSlider.setMaximum(2100)
        self.rxSlider.setOrientation(QtCore.Qt.Horizontal)
        self.rxSlider.setObjectName(_fromUtf8("rxSlider"))
        self.gridLayout_3.addWidget(self.rxSlider, 3, 3, 1, 1)
        self.label_8 = QtGui.QLabel(self.centralwidget)
        self.label_8.setObjectName(_fromUtf8("label_8"))
        self.gridLayout_3.addWidget(self.label_8, 2, 1, 1, 1)
        spacerItem1 = QtGui.QSpacerItem(40, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
        self.gridLayout_3.addItem(spacerItem1, 0, 1, 1, 1)
        spacerItem2 = QtGui.QSpacerItem(40, 10, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.gridLayout_3.addItem(spacerItem2, 0, 3, 1, 1)
        self.zSlider = QtGui.QSlider(self.centralwidget)
        self.zSlider.setEnabled(False)
        self.zSlider.setMinimum(900)
        self.zSlider.setMaximum(2100)
        self.zSlider.setOrientation(QtCore.Qt.Horizontal)
        self.zSlider.setObjectName(_fromUtf8("zSlider"))
        self.gridLayout_3.addWidget(self.zSlider, 5, 3, 1, 1)
        self.lxSlider = QtGui.QSlider(self.centralwidget)
        self.lxSlider.setEnabled(False)
        self.lxSlider.setMinimum(900)
        self.lxSlider.setMaximum(2100)
        self.lxSlider.setOrientation(QtCore.Qt.Horizontal)
        self.lxSlider.setObjectName(_fromUtf8("lxSlider"))
        self.gridLayout_3.addWidget(self.lxSlider, 1, 3, 1, 1)
        self.lxlabel = QtGui.QLabel(self.centralwidget)
        self.lxlabel.setObjectName(_fromUtf8("lxlabel"))
        self.gridLayout_3.addWidget(self.lxlabel, 1, 2, 1, 1)
        self.lylabel = QtGui.QLabel(self.centralwidget)
        self.lylabel.setObjectName(_fromUtf8("lylabel"))
        self.gridLayout_3.addWidget(self.lylabel, 2, 2, 1, 1)
        self.rxlabel = QtGui.QLabel(self.centralwidget)
        self.rxlabel.setObjectName(_fromUtf8("rxlabel"))
        self.gridLayout_3.addWidget(self.rxlabel, 3, 2, 1, 1)
        self.rylabel = QtGui.QLabel(self.centralwidget)
        self.rylabel.setObjectName(_fromUtf8("rylabel"))
        self.gridLayout_3.addWidget(self.rylabel, 4, 2, 1, 1)
        self.zlabel = QtGui.QLabel(self.centralwidget)
        self.zlabel.setObjectName(_fromUtf8("zlabel"))
        self.gridLayout_3.addWidget(self.zlabel, 5, 2, 1, 1)
        spacerItem3 = QtGui.QSpacerItem(32, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
        self.gridLayout_3.addItem(spacerItem3, 0, 2, 1, 1)
        self.gridLayout_2.addLayout(self.gridLayout_3, 0, 0, 1, 1)
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        spacerItem4 = QtGui.QSpacerItem(200, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem4, 0, 1, 1, 1)
        self.gridLayout_6 = QtGui.QGridLayout()
        self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6"))
        self.label_4 = QtGui.QLabel(self.centralwidget)
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.gridLayout_6.addWidget(self.label_4, 1, 1, 1, 1)
        self.label = QtGui.QLabel(self.centralwidget)
        self.label.setObjectName(_fromUtf8("label"))
        self.gridLayout_6.addWidget(self.label, 0, 0, 1, 1)
        self.label_3 = QtGui.QLabel(self.centralwidget)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.gridLayout_6.addWidget(self.label_3, 0, 1, 1, 1)
        self.label_2 = QtGui.QLabel(self.centralwidget)
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout_6.addWidget(self.label_2, 1, 0, 1, 1)
        self.label_5 = QtGui.QLabel(self.centralwidget)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.gridLayout_6.addWidget(self.label_5, 2, 0, 1, 1)
        self.label_6 = QtGui.QLabel(self.centralwidget)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.gridLayout_6.addWidget(self.label_6, 2, 1, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_6, 1, 1, 1, 1)
        spacerItem5 = QtGui.QSpacerItem(20, 100, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        self.gridLayout.addItem(spacerItem5, 1, 0, 1, 1)
        self.gridLayout_2.addLayout(self.gridLayout, 0, 1, 1, 1)
        self.gridLayout_5 = QtGui.QGridLayout()
        self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5"))
        spacerItem6 = QtGui.QSpacerItem(18, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.gridLayout_5.addItem(spacerItem6, 0, 0, 1, 1)
        self.gridLayout_2.addLayout(self.gridLayout_5, 1, 0, 1, 2)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 675, 23))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
        self.label_10.setText(_translate("MainWindow", "RY", None))
        self.label_9.setText(_translate("MainWindow", "RX", None))
        self.label_7.setText(_translate("MainWindow", "LX", None))
        self.label_11.setText(_translate("MainWindow", "Z", None))
        self.label_8.setText(_translate("MainWindow", "LY", None))
        self.lxlabel.setText(_translate("MainWindow", "0", None))
        self.lylabel.setText(_translate("MainWindow", "0", None))
        self.rxlabel.setText(_translate("MainWindow", "0", None))
        self.rylabel.setText(_translate("MainWindow", "0", None))
        self.zlabel.setText(_translate("MainWindow", "0", None))
        self.label_4.setText(_translate("MainWindow", "TextLabel", None))
        self.label.setText(_translate("MainWindow", "TextLabel", None))
        self.label_3.setText(_translate("MainWindow", "TextLabel", None))
        self.label_2.setText(_translate("MainWindow", "TextLabel", None))
        self.label_5.setText(_translate("MainWindow", "TextLabel", None))
        self.label_6.setText(_translate("MainWindow", "TextLabel", None))


if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140426/e2b51280/attachment-0001.html>


More information about the PyQt mailing list