Fix conflict with the batch thread. Make sure batch thread yields to the thread opening a preview. This should eliminate (all?) crashes when something is being done while batch is running.

This commit is contained in:
Andrey Skvortsov
2010-09-18 22:56:59 -07:00
parent 1464eed466
commit ce13359d38
3 changed files with 50 additions and 3 deletions

View File

@@ -29,6 +29,9 @@
#undef THREAD_PRIORITY_NORMAL
Glib::Thread *batchThread = NULL;
Glib::Mutex* qMutex = NULL;
namespace rtengine {
IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* pl) {
@@ -210,6 +213,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl) {
if (!qMutex)
qMutex = new Glib::Mutex ();
qMutex->lock();
ProcessingJob* currentJob = job;
while (currentJob) {
@@ -219,12 +226,22 @@ void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl) {
bpl->error ("Can not load input image.");
currentJob = bpl->imageReady (img);
}
qMutex->unlock();
}
void startBatchProcessing (ProcessingJob* job, BatchProcessingListener* bpl) {
if (bpl)
Glib::Thread::create(sigc::bind(sigc::ptr_fun(batchProcessingThread), job, bpl), 0, false, true, Glib::THREAD_PRIORITY_LOW);
batchThread = Glib::Thread::create(sigc::bind(sigc::ptr_fun(batchProcessingThread), job, bpl), 0, true, true, Glib::THREAD_PRIORITY_LOW);
if(qMutex)
{
delete qMutex;
qMutex = NULL;
}
}
}