[PyQt] PyQt5.1 snapshot, Qt5.1.1, ASSERT failure in QVector

Johnny Karlsson johnny.karlsson at gmail.com
Thu Oct 10 09:27:10 BST 2013


Hi! I’m experiencing a problem that might be a bug in PyQt. I've made
a code example that demonstrates the problem:

class CommClient(QObject):

   def __init__(self, parent=None):
      QObject.__init__(self)
      self._devicelist = ""
      self.timer = QTimer()
      self.timer.timeout.connect(self.test)
      self.timer.start(2000)

    def setDeviceList( self, devlist ):
        self._devicelist = devlist
        self.deviceListUpdated.emit()

    def getDevicelist(self):
        return self._devicelist

    deviceListUpdated = pyqtSignal()
    devicelist = pyqtProperty(str, getDevicelist, notify=deviceListUpdated)

    def test(self):
        self._devicelist = "YES"
        self.deviceListUpdated.emit()
        self.timer.stop()

app = QApplication(sys.argv)
qmlRegisterType(CommClient, 'SDL', 1, 0, 'CommClient')

view = QQuickView()
view.setWidth(500)
view.setHeight(500)
view.setTitle('CommClient')

view.setSource(QUrl('main.qml'))
view.show()
app.exec_()


And the QML file:

import QtQuick 2.0
import SDL 1.0

Rectangle {
    width: 400
    height: 400

   Text {
      id: myText
      text: commClient.devicelist
      anchors.horizontalCenter: parent.horizontalCenter
    }

    CommClient {
        id: commClient
    }
}

When the timer fires and the signal is emitted I get:

ASSERT failure in QVector<T>::at: "index out of range", file
../../include/QtCore/../../src/corelib/tools/qvector.h, line 350

I'm running the latest snapshot of PyQt5.1 (
PyQt-gpl-5.1.1-snapshot-41b8f6ca2ea4. ) and stable Qt5.1.1 built from
source on Ubuntu 12.04.


More information about the PyQt mailing list