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:
@@ -20,6 +20,7 @@
|
|||||||
#include <curves.h>
|
#include <curves.h>
|
||||||
#include <mytime.h>
|
#include <mytime.h>
|
||||||
#include <refreshmap.h>
|
#include <refreshmap.h>
|
||||||
|
#include <simpleprocess.h>
|
||||||
#define CLIPTO(a,b,c) ((a)>b?((a)<c?(a):c):b)
|
#define CLIPTO(a,b,c) ((a)>b?((a)<c?(a):c):b)
|
||||||
#define CLIP(a) ((a)<65535 ? (a) : (65535));
|
#define CLIP(a) ((a)<65535 ? (a) : (65535));
|
||||||
|
|
||||||
@@ -561,7 +562,7 @@ void ImProcCoordinator::stopProcessing () {
|
|||||||
|
|
||||||
void ImProcCoordinator::startProcessing () {
|
void ImProcCoordinator::startProcessing () {
|
||||||
|
|
||||||
#undef THREAD_PRIORITY_LOW
|
#undef THREAD_PRIORITY_NORMAL
|
||||||
|
|
||||||
if (!destroying) {
|
if (!destroying) {
|
||||||
updaterThreadStart.lock ();
|
updaterThreadStart.lock ();
|
||||||
@@ -569,7 +570,11 @@ void ImProcCoordinator::startProcessing () {
|
|||||||
thread = NULL;
|
thread = NULL;
|
||||||
updaterRunning = true;
|
updaterRunning = true;
|
||||||
updaterThreadStart.unlock ();
|
updaterThreadStart.unlock ();
|
||||||
thread = Glib::Thread::create(sigc::mem_fun(*this, &ImProcCoordinator::process), 0, false, true, Glib::THREAD_PRIORITY_LOW);
|
|
||||||
|
batchThread->yield(); //the running batch should wait other threads to avoid conflict
|
||||||
|
|
||||||
|
thread = Glib::Thread::create(sigc::mem_fun(*this, &ImProcCoordinator::process), 0, true, true, Glib::THREAD_PRIORITY_NORMAL);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
updaterThreadStart.unlock ();
|
updaterThreadStart.unlock ();
|
||||||
|
@@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
#undef THREAD_PRIORITY_NORMAL
|
#undef THREAD_PRIORITY_NORMAL
|
||||||
|
|
||||||
|
Glib::Thread *batchThread = NULL;
|
||||||
|
Glib::Mutex* qMutex = NULL;
|
||||||
|
|
||||||
namespace rtengine {
|
namespace rtengine {
|
||||||
|
|
||||||
IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* pl) {
|
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) {
|
void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl) {
|
||||||
|
|
||||||
|
if (!qMutex)
|
||||||
|
qMutex = new Glib::Mutex ();
|
||||||
|
|
||||||
|
qMutex->lock();
|
||||||
ProcessingJob* currentJob = job;
|
ProcessingJob* currentJob = job;
|
||||||
|
|
||||||
while (currentJob) {
|
while (currentJob) {
|
||||||
@@ -219,12 +226,22 @@ void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl) {
|
|||||||
bpl->error ("Can not load input image.");
|
bpl->error ("Can not load input image.");
|
||||||
currentJob = bpl->imageReady (img);
|
currentJob = bpl->imageReady (img);
|
||||||
}
|
}
|
||||||
|
qMutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void startBatchProcessing (ProcessingJob* job, BatchProcessingListener* bpl) {
|
void startBatchProcessing (ProcessingJob* job, BatchProcessingListener* bpl) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
25
rtengine/simpleprocess.h
Normal file
25
rtengine/simpleprocess.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* File: simpleprocess.h
|
||||||
|
* Author: askv
|
||||||
|
*
|
||||||
|
* Created on September 18, 2010, 8:31 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLEPROCESS_H
|
||||||
|
#define SIMPLEPROCESS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern Glib::Thread *batchThread;
|
||||||
|
|
||||||
|
#endif /* SIMPLEPROCESS_H */
|
||||||
|
|
Reference in New Issue
Block a user