chipmuenk / A2SRC

Python scripts and documentation on Asynchronous Audio Sample Rate Conversion
Apache License 2.0
1 stars 3 forks source link

Possible problem when subclassing QThread #2

Open OshinoMoumou opened 3 years ago

OshinoMoumou commented 3 years ago

Greetings! I noticed that class Thread referred a StackOverflow post, while a recent comment to it mentioned that subclassing QThread is always the wrong thing to do, because the QThread object lives in the parent thread; ergo, slots signaled on this object run in the parent thread rather than the actual thread encapsulated by the QThread object. Signal-slot connections are the entire basis for thread synchronization in Qt. Ergo, subclassing QThread obstructs synchronization. . I'm trying to learn the usefulness of such small updates on StackOverflow. Would this comment help improve your code? I understand that such defect might not happen in real life situation. In that case, do you think this comment can help prevent future bugs (for example, when the code were reused somewhere else)? I'll really appreciate it if you could kindly give me some feedback or suggestions. Thank you very much for your time. Have a nice day!

chipmuenk commented 3 years ago

Greetings! If I understand you correctly, you're not asking about the code but whether your comment makes a difference and helps me (and other users) to avoid bugs and write better code?

The answer is: YES! Thanks a lot for your suggestion, the code you're referring to is several years old and my coding skills at that time were even more limited than they are now. But I will need Threading in my main project (pyfda) in the very near future which makes your input especially valuable for me - perfect timing! Please do comment on other people's code, that's the essence of StackOverflow.

I think I will start with cleaning up and updating this repo before I transfer some of the code to pyfda.