[pyqt] Slot crashed in secondary thread without error and works in GUI thread
-
Hi,
To get more information about the crash you can use pdb or ipdb and start you script from there.
-
Hi,
Same behavior when using ipdb, no error message.I found out tha tif I import he thorlabs_apt library from within the slots it works.
How can it be? Is that something that often happen and shall I keep my code this way?
This does not sound very "clean"... -
Can't you step in your code until the crash happens ?
-
@Thombou said in [pyqt] Slot crashed in secondary thread without error and works in GUI thread:
I instantiate an object of a class that has been defined in the main thread?
What does that mean? If you create the instance in the correct thread then all is fine. A class is not "defined" in a thread.
-
@jsulm said in [pyqt] Slot crashed in secondary thread without error and works in GUI thread:
@Thombou said in [pyqt] Slot crashed in secondary thread without error and works in GUI thread:
I instantiate an object of a class that has been defined in the main thread?
What does that mean? If you create the instance in the correct thread then all is fine. A class is not "defined" in a thread.
Technically, a class definition does happen within a particular thread in python or likely any other interpreted language. It's possible that the definition creates or captures a QObject reference, making the class unusable from other threads.
The same general hazard is possible in C++ with lambda objects with captures, use of global QObjects, and likely additional scenarios.
I don't have any reason to suspect the OP is doing this. If I'm wrong, stop doing this!
-