Merge branch 'dev' into review-idle_register-calls
This commit is contained in:
@@ -39,6 +39,25 @@
|
||||
using namespace std;
|
||||
using namespace rtengine;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
struct NLParams {
|
||||
BatchQueueListener* listener;
|
||||
int qsize;
|
||||
bool queueRunning;
|
||||
bool queueError;
|
||||
Glib::ustring queueErrorMessage;
|
||||
};
|
||||
|
||||
bool bqnotifylistenerUI(NLParams* params)
|
||||
{
|
||||
params->listener->queueSizeChanged (params->qsize, params->queueRunning, params->queueError, params->queueErrorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCatalog(aFileCatalog), sequence(0), listener(nullptr)
|
||||
{
|
||||
|
||||
@@ -208,7 +227,7 @@ void BatchQueue::addEntries (const std::vector<BatchQueueEntry*>& entries, bool
|
||||
saveBatchQueue ();
|
||||
|
||||
redraw ();
|
||||
notifyListener (false);
|
||||
notifyListener ();
|
||||
}
|
||||
|
||||
bool BatchQueue::saveBatchQueue ()
|
||||
@@ -366,7 +385,7 @@ bool BatchQueue::loadBatchQueue ()
|
||||
}
|
||||
|
||||
redraw ();
|
||||
notifyListener (false);
|
||||
notifyListener ();
|
||||
|
||||
return !fd.empty ();
|
||||
}
|
||||
@@ -437,7 +456,7 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
saveBatchQueue ();
|
||||
|
||||
redraw ();
|
||||
notifyListener (false);
|
||||
notifyListener ();
|
||||
}
|
||||
|
||||
void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
@@ -574,6 +593,8 @@ void BatchQueue::startProcessing ()
|
||||
// start batch processing
|
||||
rtengine::startBatchProcessing (next->job, this);
|
||||
queue_draw ();
|
||||
|
||||
notifyListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -585,13 +606,14 @@ void BatchQueue::setProgress(double p)
|
||||
}
|
||||
|
||||
// No need to acquire the GUI, setProgressUI will do it
|
||||
idle_register.add(
|
||||
[this]() -> bool
|
||||
const auto func =
|
||||
[](BatchQueue* bq) -> bool
|
||||
{
|
||||
redraw();
|
||||
bq->redraw();
|
||||
return false;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
idle_register.add<BatchQueue>(func, this, false);
|
||||
}
|
||||
|
||||
void BatchQueue::setProgressStr(const Glib::ustring& str)
|
||||
@@ -616,15 +638,12 @@ void BatchQueue::error(const Glib::ustring& descr)
|
||||
}
|
||||
|
||||
if (listener) {
|
||||
BatchQueueListener* const listener_copy = listener;
|
||||
|
||||
idle_register.add(
|
||||
[listener_copy, descr]() -> bool
|
||||
{
|
||||
listener_copy->queueSizeChanged(0, false, true, descr);
|
||||
return false;
|
||||
}
|
||||
);
|
||||
NLParams* params = new NLParams;
|
||||
params->listener = listener;
|
||||
params->queueRunning = false;
|
||||
params->queueError = true;
|
||||
params->queueErrorMessage = descr;
|
||||
idle_register.add<NLParams>(bqnotifylistenerUI, params, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,7 +706,6 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
|
||||
Glib::ustring processedParams = processing->savedParamsFile;
|
||||
|
||||
// delete from the queue
|
||||
bool queueEmptied = false;
|
||||
bool remove_button_set = false;
|
||||
|
||||
{
|
||||
@@ -699,9 +717,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
|
||||
fd.erase (fd.begin());
|
||||
|
||||
// return next job
|
||||
if (fd.empty()) {
|
||||
queueEmptied = true;
|
||||
} else if (listener && listener->canStartNext ()) {
|
||||
if (!fd.empty() && listener && listener->canStartNext ()) {
|
||||
BatchQueueEntry* next = static_cast<BatchQueueEntry*>(fd[0]);
|
||||
// tag it as selected and set sequence
|
||||
next->processing = true;
|
||||
@@ -759,7 +775,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
|
||||
}
|
||||
|
||||
redraw ();
|
||||
notifyListener (queueEmptied);
|
||||
notifyListener ();
|
||||
|
||||
return processing ? processing->job : nullptr;
|
||||
}
|
||||
@@ -954,25 +970,19 @@ void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionDa
|
||||
}
|
||||
}
|
||||
|
||||
void BatchQueue::notifyListener (bool queueEmptied)
|
||||
void BatchQueue::notifyListener ()
|
||||
{
|
||||
|
||||
const bool queueRunning = processing;
|
||||
if (listener) {
|
||||
BatchQueueListener* const listener_copy = listener;
|
||||
const std::size_t queue_size =
|
||||
[](MyRWMutex& mutex, const std::vector<ThumbBrowserEntryBase*>& fd) -> std::size_t
|
||||
{
|
||||
MYREADERLOCK(l, mutex);
|
||||
return fd.size();
|
||||
}(entryRW, fd);
|
||||
|
||||
idle_register.add(
|
||||
[listener_copy, queue_size, queueEmptied]() -> bool
|
||||
{
|
||||
listener_copy->queueSizeChanged(queue_size, queueEmptied, false, {});
|
||||
return false;
|
||||
}
|
||||
);
|
||||
NLParams* params = new NLParams;
|
||||
params->listener = listener;
|
||||
{
|
||||
MYREADERLOCK(l, entryRW);
|
||||
params->qsize = fd.size();
|
||||
}
|
||||
params->queueRunning = queueRunning;
|
||||
params->queueError = false;
|
||||
idle_register.add<NLParams>(bqnotifylistenerUI, params, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user