[PyKDE] crash after populating list view from separate thread

Christopher J. Bottaro cjbottaro at alumni.cs.utexas.edu
Sat Feb 5 19:13:50 GMT 2005


My my program starts up, I have to populate a list view.  There are many
items (over 5000), so I opted to do it in a separate thread.  Now, I'm
pretty new to QT (and KDE) programming, so I suspect I'm doing this
"wrong".  Please take a look and see...

---

class PopulatingThread(QThread):
   def __init__(self, prog):
      QThread.__init__(self)
      self.prog = prog

   def run(self):
      self.prog.PopulateListView()

class MyProg(KMainWindow):
   def __init__(self, *argv):
      KMainWindow.__init__(self, *argv)
      self.list_view = KListView(...)
      self.list_view_search = KListViewSearchLine(..., self.list_view)
      self.thread = PopulatingThread(self)
      self.thread.start()

   def PopulateListView(self):
      for item in some_item_list:
         KListViewItem(self.list_view, item)

---

The problem is that when the thread finishes, the program crashes.  The
program doesn't crash if I call PopulateListView() directly from
__init__(), but then of course GUI locks up, progress bars don't completely
show, etc.

Any ideas?  Thanks for the help.




More information about the PyQt mailing list