diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index 8cfed601d..09fe0ce40 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -8973,6 +8973,13 @@ dcrMutex->lock (); image = (UshORt (*)[4])calloc (height*width*sizeof *image + meta_length, 1); meta_data = (char *) (image + height*width); + if(!image) + { + fclose(ifp); + dcrMutex->unlock (); + return 3; + } + if (setjmp (failure)) { if (image) free (image); diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 2e90e9eb8..1e78cb320 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -25,14 +25,15 @@ ThumbImageUpdater thumbImageUpdater; ThumbImageUpdater::ThumbImageUpdater () : tostop(false), stopped(true), qMutex(NULL), startMutex(NULL) { - threadPool = new Glib::Thread* [threadNum]; - + //threadPool = new Glib::Thread* [threadNum]; + threadPool = 0;; + } -ThumbImageUpdater::~ThumbImageUpdater () -{ - delete threadPool; -} +//ThumbImageUpdater::~ThumbImageUpdater () +//{ +// delete threadPool; +//} void ThumbImageUpdater::add (Thumbnail* t, const rtengine::procparams::ProcParams& params, int height, bool* priority, ThumbImageUpdateListener* l) { @@ -69,7 +70,15 @@ void ThumbImageUpdater::process () { if (stopped) { #undef THREAD_PRIORITY_LOW stopped = false; + // if (thread) + // thread->join(); + + if(!threadPool) + threadPool = new Glib::ThreadPool(4,0); thread = Glib::Thread::create(sigc::mem_fun(*this, &ThumbImageUpdater::process_), (unsigned long int)0, true, true, Glib::THREAD_PRIORITY_LOW); + //qMutex->lock (); + // threadPool->push(sigc::mem_fun(*this, &ThumbImageUpdater::process_)); + //qMutex->unlock (); } } @@ -78,34 +87,50 @@ void ThumbImageUpdater::process_ () { stopped = false; tostop = false; - + // GError *err; while (!tostop && !jqueue.empty ()) { qMutex->lock (); - int threads = 0; - for (; threads::iterator i; for (i=jqueue.begin (); i!=jqueue.end(); i++) if (*(i->priority)) break; + + if (i==jqueue.end()) i = jqueue.begin(); - Job current = *i; + + Job current = *i; + if (current.listener) + threadPool->push(sigc::bind(sigc::mem_fun(*this, &ThumbImageUpdater::processJob), current)); + +// if(! threadPool) +// threadPool = g_thread_pool_new((void*)&ThumbImageUpdater::processJob, (gpointer)¤t, 4, FALSE, &err); +// else +// g_thread_pool_push(threadPool, (gpointer)current, &err); + + //threadPool[threads] = + // Glib::Thread::create (sigc::bind(sigc::mem_fun(*this, &ThumbImageUpdater::processJob), current), 0, false, true, Glib::THREAD_PRIORITY_LOW); + jqueue.erase (i); - if (current.listener) - threadPool[threads] = Glib::Thread::create(sigc::bind(sigc::mem_fun(*this, &ThumbImageUpdater::processJob), current), 0, true, true, Glib::THREAD_PRIORITY_LOW); //else // threadPool[threads] = NULL; - } + // } qMutex->unlock (); - for (int j=0; jjoin (); + // for (int j=0; j join (); - for(int j =0; j yield(); - if (!stopped) - thread->join (); + tostop = true; + + Glib::Thread::self()->yield(); + if (!stopped) + threadPool->shutdown(TRUE); + thread->join (); gdk_threads_enter(); } diff --git a/rtgui/thumbimageupdater.h b/rtgui/thumbimageupdater.h index 916d453eb..e804ec159 100644 --- a/rtgui/thumbimageupdater.h +++ b/rtgui/thumbimageupdater.h @@ -22,6 +22,7 @@ #include #include #include +#include class ThumbImageUpdateListener { @@ -46,11 +47,11 @@ class ThumbImageUpdater { Glib::Thread* thread; Glib::Mutex* qMutex; Glib::Mutex* startMutex; - Glib::Thread **threadPool; + //Glib::Thread **threadPool; + Glib::ThreadPool * threadPool; public: - ThumbImageUpdater (); - ~ThumbImageUpdater (); + ThumbImageUpdater (); void add (Thumbnail* t, const rtengine::procparams::ProcParams& params, int height, bool* priority, ThumbImageUpdateListener* l); void process ();