From 301c8fa2b64929dd079d9f16c8f245f078a6ac83 Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Fri, 4 Feb 2011 19:33:51 +0100 Subject: [PATCH] Fixed issue #518 (Occasional crash using batch queue) --- rtgui/bqentryupdater.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/rtgui/bqentryupdater.cc b/rtgui/bqentryupdater.cc index 3ad75b669..4268180dc 100644 --- a/rtgui/bqentryupdater.cc +++ b/rtgui/bqentryupdater.cc @@ -69,12 +69,20 @@ void BatchQueueEntryUpdater::process_ () { tostop = false; // TODO: process visible jobs first - while (!tostop && !jqueue.empty ()) { + bool isEmpty=false; + + while (!tostop && !isEmpty) { + qMutex->lock (); - Job current = jqueue.front (); + isEmpty=jqueue.empty (); // do NOT put into while() since it must be within mutex section + Job current; + if (!isEmpty) { + current = jqueue.front (); jqueue.pop_front (); + } qMutex->unlock (); - if (current.listener) { + + if (!isEmpty && current.listener) { int neww = current.newh * current.ow / current.oh; guint8* img = new guint8 [current.newh*neww*3]; thumbInterp (current.oimg, current.ow, current.oh, img, neww, current.newh);