Pyside QThreadPool problem



  • Hi! I have problem with QThreadPool. Then object derived from QRunnable contains some other object, program crush on exit (The instruction at "0x1e0154ac" referenced memory at "0x00000028". The memory could not be "read"). Here is a minimal code:
    @#!/usr/bin/python

    -- coding: utf-8 --

    import sys
    from PySide.QtCore import *
    from PySide.QtGui import *

    class Test:
    def init(_self):
    pass

    class TestThread(QRunnable, QObject):
    def init(_self, _parent = None):
    QObject.init(_self)
    QRunnable.init(_self, _parent)

    _self.setAutoDelete(False)
    
    #if comment next line, all ok.
    _self.obj_ = Test()
    #_self.obj_ = "some text" - this working too.
    

    def run(_self):
    return

    class Window(QMainWindow):
    def init(_self, _parent = None):
    QMainWindow.init(_self, _parent)

    _self.threadPool = QThreadPool()
    
    _self.threads = []
    for i in range(2):
      _self.threads.append(TestThread())
    
    _self.testMethod()
    

    def testMethod(_self):
    for threadObj in _self.threads:
    _self.threadPool.start(threadObj)

    if name == 'main':
    app = QApplication(sys.argv)
    form = Window()
    form.show()
    sys.exit(app.exec_())@

    Edit: improved code style



  • By changing line 7:
    @class Test:@

    to
    @class Test(object):@

    it's not running into segfaults anymore on my system.

    Using old-style classes (not using the ultimate 'object' base class) in Python is being discouraged for quite some time now and this makes me think PySide can't handle them, or this is just a bug.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.