[Qt-interest] QTimer and crashing...

Brad Howes howes at ll.mit.edu
Wed Aug 4 03:25:49 CEST 2010


On Aug 3, 2010, at 2:57 PM, BRM wrote:

> Am I doing something wrong? Or should I be filing a bug with Nokia/Qt?


Most likely, you are doing something wrong.

It is difficult to debug another's program, but since I have a highly multithreaded UDP and TCP application running using Qt's networking infrastructure and it does not crash, the evidence from my point of view points to your code as the source of the problem, not Qt. These are notoriously hard things to nail down. The best course of action, IMO, is to strip away the complexity (you don't need much to make this stuff work). I think your approach with the QTimer is misguided -- I would have worked on solving the original problem of the missing data.

In my case, I have applications that publish and/or subscribe to over 15 channels of data, simultaneously. The main transport is UDP, but there is a TCP connection to for XML status and remote control XML-RPC messages. The only reason I have a timer in my setup is to periodically send out a heart-beat message to the publishers to keep them sending out data. Everything else is event driven, including the service discovery mechanism I use for the publishers based on Zeroconf. The key to my sanity while getting all of this to work right has been to keep my classes focused and simple; to fully understand and enforce data ownership rules; to use practice safe-threading through the proper use of thread-protected queues. Whenever I sometimes think I can get away with something in a threaded environment, I have always been proven wrong, especially at high data rates. Simplicity rules.

Oh, and don't forget that the select() call still rocks and can often outperform naive threaded implementations along the lines of one thread per socket model.

Good luck!

Brad

-- 
Brad Howes
Group 42
MIT Lincoln Laboratory • 244 Wood St. • Lexington, MA 02173
Phone: 781.981.5292 • Fax: 781.981.3495 • Secretary: 781.981.7420









More information about the Qt-interest-old mailing list