Hi all.

I have weired problem with signals sending between threads.

1) I have a thread. In the run() function I create a signals reciever object and connect signals to it:
Qt Code:
  1. void LogServiceThread::run()
  2. {
  3. // Create worker.
  4. try
  5. {
  6. m_impl->m_worker.reset(new LogWorker(m_impl->m_fileName));
  7. }
  8. catch (...)
  9. {
  10. // Ignore all exceptions. If something gone wrong with worker - continue work silently.
  11. }
  12. // Connect signals to worker.
  13. if (!m_impl->m_worker.isNull())
  14. {
  15. connect(this, SIGNAL(writeAsynchSignal(QString)), m_impl->m_worker.data(), SLOT(writeMessage(QString)), Qt::QueuedConnection);
  16. }
  17. // Run event loop.
  18. exec();
  19. }
To copy to clipboard, switch view to plain text mode 
2) Now I try to send som signals to it by main thread
Qt Code:
  1. void LogServiceThread::writeAsynch(const QString & string)
  2. {
  3. emit writeAsynchSignal(string);
  4. }
To copy to clipboard, switch view to plain text mode 

So basically, this is an asynchronous thread safe logger. And I got weired problem: sometimes SOME log messages are missing. Some signals are emited but never come to slot! Sometimes I got all messages during run, some times only few.

What I am missing?

Thanks.