Commit 6cd122f9 authored by Jan Möbius's avatar Jan Möbius
Browse files

Switched QMutex for OpenFlipperThread startup to QSemaphore to be able to call...

Switched QMutex for OpenFlipperThread startup to QSemaphore to be able to call it across processes. Otherwise Windows Qt crashes in debug mode. Removed debug output

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0be66c8b
......@@ -38,12 +38,9 @@ OpenFlipperThread::OpenFlipperThread( QString _jobId ) :
OpenFlipperThread::~OpenFlipperThread() {
std::cerr << "Destructor Thread" << std::endl;
void OpenFlipperThread::run()
......@@ -62,17 +59,13 @@ void OpenFlipperThread::run()
// connect the function to start the job
std::cerr << "Start Event Loop" << std::endl;
// Start event queue
// Thread is ready for processing now, tell core that we can continue.
// Start event queue (possibly added events are already queued here
std::cerr << "End Event Loop " << std::endl;
// TODO: Self destuction sometimes does not work!
// Seems to be a race condition!!!
......@@ -102,25 +95,20 @@ void OpenFlipperThread::slotJobFinished( ) {
void OpenFlipperThread::startProcessing() {
std::cerr << "Thread emit startProcessing" << std::endl;
// Wait for thread to come up with event loop ... otherwise the signals might get lost
// Wait for thread to come up and connect its signals ... otherwise the signals might get lost
// Tell internal wrapper to start with the processing
emit startProcessingInternal();
std::cerr << "Thread emit startProcessing done" << std::endl;
std::cerr << "Destructor job called" << std::endl;
void OpenFlipperJob::startJobProcessing() {
std::cerr << "job start process" << std::endl;
// Actually start the process ( This function will block as it uses a direct connection )
// But it only blocks the current thread.
emit process();
......@@ -130,6 +118,4 @@ void OpenFlipperJob::startJobProcessing() {
// Cleanup this object
std::cerr << "processing done" << std::endl;
......@@ -34,7 +34,7 @@
#include <QThread>
#include <QMutex>
#include <QSemaphore>
#include <OpenFlipper/common/GlobalDefines.hh>
......@@ -221,7 +221,15 @@ class DLLEXPORT OpenFlipperThread : public QThread
QString jobId_;
QMutex startup_;
/** \brief Semaphore to control order of thread startup calls
* This variable is used to control the order of thread startup calls. The Thread itself is
* started, and when it is up and running, the resource will be created. The core thread waits
* for this resource and afterwards starts execution of the threads processing function.
* Without this sync, the processing call of the main thread might get lost as the thread is
* not online and listening for the signal.
QSemaphore startup_;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment