Hey,

I have a problem with my QThreads (running on windows). It is the first time I use multithreading, so I am probably doing something wrong ;)

The situation is as follows: I have a QTreeWidget which works like a filebrowser, listing a few thousand files. Creating the treeitems from the files is pretty fast, but I also want the treeWidget to display more information about the files. This is taking some time depending on the quantity of the files. So what I did is to first fill the treeView with all the filenames. After that, I start an update-threat, which loops through all the items in the treeWidget, gathers its data and fills the additional columns in the treeView with the data. While the thread is updating the treeWidget, the user can already work with the files and does not need to wait for the update to finish.

This all works pretty well.

The problem now is that the user can do actions which will change the filelist in the treeWidget (like changing the directory). Doing this, the update thread tries to update items that do not longer exist in the treeWidget and produce errors or just crashes. My first idea was to just terminate the thread when the user does an action which will change the filelist. This seemed to work on first sight, but now my programm crashes really often without any error given.

So, maybe someone has some tips about creating a safe thread which can handle this? Or is there any way to check inside my updatethread if the items it wants to update still exists?

Thanks for your time and help,
Andre

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to