Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Pyside QThreadPool problem
Forum Updated to NodeBB v4.3 + New Features

Pyside QThreadPool problem

Scheduled Pinned Locked Moved Language Bindings
2 Posts 2 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    networm
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gertvdijk
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved