Commit a4d1777b authored by Mike Kremer's avatar Mike Kremer

Added optional parameter to function() signal to receive the job's id.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9251 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d39d90b8
......@@ -47,11 +47,11 @@ void OpenFlipperThread::run()
{
if ( job_ == 0 ) {
// Create a job wrapper to run a slot from within this thread
job_ = new OpenFlipperJob();
job_ = new OpenFlipperJob( jobId_ );
// Connect the slot which should run in this thread. This has to be a DirectConnection !
// Otherwisse the slot will run inside its owner context which will be the main loop!!
connect(job_, SIGNAL(process()),this,SIGNAL(function() ),Qt::DirectConnection);
connect(job_, SIGNAL(process(QString)),this,SIGNAL(function(QString) ),Qt::DirectConnection);
// Connect the jobs finished function
connect(job_, SIGNAL(finished()),this,SLOT(slotJobFinished() ) );
......@@ -111,7 +111,7 @@ void OpenFlipperJob::startJobProcessing() {
// Actually start the process ( This function will block as it uses a direct connection )
// But it only blocks the current thread.
emit process();
emit process(jobId_);
// Tell thread that the job is done.
emit finished();
......
......@@ -166,8 +166,11 @@ class DLLEXPORT OpenFlipperThread : public QThread
* However you should only use this function if you Dont know how long your job takes. Or when
* you just want to keep the core responding.\n
* Otherwise you should reimplement the run(), and cancel() function of OpenFlipperThread and emit the state signal.
*
* The optional parameter contains the job's id. In some cases the function that is to be called needs
* the job's id for further processing (status updates, etc.)
*/
void function();
void function(const QString _jobId = "");
/** \brief job done
*
......@@ -231,7 +234,6 @@ class DLLEXPORT OpenFlipperThread : public QThread
*/
QSemaphore startup_;
};
......@@ -254,7 +256,7 @@ class DLLEXPORT OpenFlipperJob : public QObject
Q_OBJECT
public:
OpenFlipperJob() {}
OpenFlipperJob(const QString _jobId) : jobId_(_jobId) {}
~OpenFlipperJob();
signals:
......@@ -265,7 +267,7 @@ class DLLEXPORT OpenFlipperJob : public QObject
* If this object is created in a QThread, than the slot will be run
* inside this thread.
*/
void process();
void process(const QString _jobId = "");
/** \brief Job done
*
......@@ -281,6 +283,16 @@ class DLLEXPORT OpenFlipperJob : public QObject
*/
void startJobProcessing();
public:
/// Set job's id
void jobId(const QString& _jobId) { jobId_ = _jobId; }
/// Get job's id
QString jobId() const { return jobId_; }
private:
/// The job's id
QString jobId_;
};
......
Markdown is supported
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