Reenable batch queue interface on queue length notification

This removes the need for canStartNext() to do any UI updates.
This commit is contained in:
George Hilliard
2018-10-26 00:52:15 -05:00
parent 52c943ca0e
commit 7d5fe6d1c8
3 changed files with 18 additions and 18 deletions

View File

@@ -45,7 +45,7 @@ namespace
struct NLParams { struct NLParams {
BatchQueueListener* listener; BatchQueueListener* listener;
int qsize; int qsize;
bool queueEmptied; bool queueRunning;
bool queueError; bool queueError;
Glib::ustring queueErrorMessage; Glib::ustring queueErrorMessage;
}; };
@@ -53,7 +53,7 @@ struct NLParams {
int bqnotifylistenerUI (void* data) int bqnotifylistenerUI (void* data)
{ {
NLParams* params = static_cast<NLParams*>(data); NLParams* params = static_cast<NLParams*>(data);
params->listener->queueSizeChanged (params->qsize, params->queueEmptied, params->queueError, params->queueErrorMessage); params->listener->queueSizeChanged (params->qsize, params->queueRunning, params->queueError, params->queueErrorMessage);
delete params; delete params;
return 0; return 0;
} }
@@ -229,7 +229,7 @@ void BatchQueue::addEntries (const std::vector<BatchQueueEntry*>& entries, bool
saveBatchQueue (); saveBatchQueue ();
redraw (); redraw ();
notifyListener (false); notifyListener (true);
} }
bool BatchQueue::saveBatchQueue () bool BatchQueue::saveBatchQueue ()
@@ -387,7 +387,7 @@ bool BatchQueue::loadBatchQueue ()
} }
redraw (); redraw ();
notifyListener (false); notifyListener (true);
return !fd.empty (); return !fd.empty ();
} }
@@ -460,7 +460,7 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
saveBatchQueue (); saveBatchQueue ();
redraw (); redraw ();
notifyListener (false); notifyListener (true);
} }
void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items) void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
@@ -640,7 +640,7 @@ void BatchQueue::error(const Glib::ustring& descr)
if (listener) { if (listener) {
NLParams* params = new NLParams; NLParams* params = new NLParams;
params->listener = listener; params->listener = listener;
params->queueEmptied = false; params->queueRunning = false;
params->queueError = true; params->queueError = true;
params->queueErrorMessage = descr; params->queueErrorMessage = descr;
idle_register.add(bqnotifylistenerUI, params); idle_register.add(bqnotifylistenerUI, params);
@@ -706,7 +706,6 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
Glib::ustring processedParams = processing->savedParamsFile; Glib::ustring processedParams = processing->savedParamsFile;
// delete from the queue // delete from the queue
bool queueEmptied = false;
bool remove_button_set = false; bool remove_button_set = false;
{ {
@@ -718,9 +717,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
fd.erase (fd.begin()); fd.erase (fd.begin());
// return next job // return next job
if (fd.empty()) { if (!fd.empty() && listener && listener->canStartNext ()) {
queueEmptied = true;
} else if (listener && listener->canStartNext ()) {
BatchQueueEntry* next = static_cast<BatchQueueEntry*>(fd[0]); BatchQueueEntry* next = static_cast<BatchQueueEntry*>(fd[0]);
// tag it as selected and set sequence // tag it as selected and set sequence
next->processing = true; next->processing = true;
@@ -778,7 +775,8 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
} }
redraw (); redraw ();
notifyListener (queueEmptied); const bool queueRunning = (processing != nullptr);
notifyListener (queueRunning);
return processing ? processing->job : nullptr; return processing ? processing->job : nullptr;
} }
@@ -973,7 +971,7 @@ void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionDa
} }
} }
void BatchQueue::notifyListener (bool queueEmptied) void BatchQueue::notifyListener (bool queueRunning)
{ {
if (listener) { if (listener) {
@@ -983,7 +981,7 @@ void BatchQueue::notifyListener (bool queueEmptied)
MYREADERLOCK(l, entryRW); MYREADERLOCK(l, entryRW);
params->qsize = fd.size(); params->qsize = fd.size();
} }
params->queueEmptied = queueEmptied; params->queueRunning = queueRunning;
params->queueError = false; params->queueError = false;
idle_register.add(bqnotifylistenerUI, params); idle_register.add(bqnotifylistenerUI, params);
} }

View File

@@ -31,7 +31,7 @@ class BatchQueueListener
public: public:
virtual ~BatchQueueListener() = default; virtual ~BatchQueueListener() = default;
virtual void queueSizeChanged(int qsize, bool queueEmptied, bool queueError, const Glib::ustring& queueErrorMessage) = 0; virtual void queueSizeChanged(int qsize, bool queueRunning, bool queueError, const Glib::ustring& queueErrorMessage) = 0;
virtual bool canStartNext() = 0; virtual bool canStartNext() = 0;
}; };
@@ -93,7 +93,7 @@ protected:
Glib::ustring autoCompleteFileName (const Glib::ustring& fileName, const Glib::ustring& format); Glib::ustring autoCompleteFileName (const Glib::ustring& fileName, const Glib::ustring& format);
Glib::ustring getTempFilenameForParams( const Glib::ustring &filename ); Glib::ustring getTempFilenameForParams( const Glib::ustring &filename );
bool saveBatchQueue (); bool saveBatchQueue ();
void notifyListener (bool queueEmptied); void notifyListener (bool queueRunning);
BatchQueueEntry* processing; // holds the currently processed image BatchQueueEntry* processing; // holds the currently processed image
FileCatalog* fileCatalog; FileCatalog* fileCatalog;

View File

@@ -245,7 +245,7 @@ void BatchQueuePanel::updateTab (int qsize, int forceOrientation)
} }
} }
void BatchQueuePanel::queueSizeChanged(int qsize, bool queueEmptied, bool queueError, const Glib::ustring& queueErrorMessage) void BatchQueuePanel::queueSizeChanged(int qsize, bool queueRunning, bool queueError, const Glib::ustring& queueErrorMessage)
{ {
updateTab (qsize); updateTab (qsize);
@@ -255,12 +255,14 @@ void BatchQueuePanel::queueSizeChanged(int qsize, bool queueEmptied, bool queueE
qStartStop->set_sensitive(true); qStartStop->set_sensitive(true);
} }
if (queueEmptied || queueError) { if (!queueRunning) {
stopBatchProc (); stopBatchProc ();
fdir->set_sensitive (true); fdir->set_sensitive (true);
fformat->set_sensitive (true); fformat->set_sensitive (true);
SoundManager::playSoundAsync(options.sndBatchQueueDone); if (qsize == 0) {
SoundManager::playSoundAsync(options.sndBatchQueueDone);
}
} }
if (queueError) { if (queueError) {