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 {
BatchQueueListener* listener;
int qsize;
bool queueEmptied;
bool queueRunning;
bool queueError;
Glib::ustring queueErrorMessage;
};
@@ -53,7 +53,7 @@ struct NLParams {
int bqnotifylistenerUI (void* 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;
return 0;
}
@@ -229,7 +229,7 @@ void BatchQueue::addEntries (const std::vector<BatchQueueEntry*>& entries, bool
saveBatchQueue ();
redraw ();
notifyListener (false);
notifyListener (true);
}
bool BatchQueue::saveBatchQueue ()
@@ -387,7 +387,7 @@ bool BatchQueue::loadBatchQueue ()
}
redraw ();
notifyListener (false);
notifyListener (true);
return !fd.empty ();
}
@@ -460,7 +460,7 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
saveBatchQueue ();
redraw ();
notifyListener (false);
notifyListener (true);
}
void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
@@ -640,7 +640,7 @@ void BatchQueue::error(const Glib::ustring& descr)
if (listener) {
NLParams* params = new NLParams;
params->listener = listener;
params->queueEmptied = false;
params->queueRunning = false;
params->queueError = true;
params->queueErrorMessage = descr;
idle_register.add(bqnotifylistenerUI, params);
@@ -706,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;
{
@@ -718,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;
@@ -778,7 +775,8 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
}
redraw ();
notifyListener (queueEmptied);
const bool queueRunning = (processing != nullptr);
notifyListener (queueRunning);
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) {
@@ -983,7 +981,7 @@ void BatchQueue::notifyListener (bool queueEmptied)
MYREADERLOCK(l, entryRW);
params->qsize = fd.size();
}
params->queueEmptied = queueEmptied;
params->queueRunning = queueRunning;
params->queueError = false;
idle_register.add(bqnotifylistenerUI, params);
}

View File

@@ -31,7 +31,7 @@ class BatchQueueListener
public:
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;
};
@@ -93,7 +93,7 @@ protected:
Glib::ustring autoCompleteFileName (const Glib::ustring& fileName, const Glib::ustring& format);
Glib::ustring getTempFilenameForParams( const Glib::ustring &filename );
bool saveBatchQueue ();
void notifyListener (bool queueEmptied);
void notifyListener (bool queueRunning);
BatchQueueEntry* processing; // holds the currently processed image
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);
@@ -255,13 +255,15 @@ void BatchQueuePanel::queueSizeChanged(int qsize, bool queueEmptied, bool queueE
qStartStop->set_sensitive(true);
}
if (queueEmptied || queueError) {
if (!queueRunning) {
stopBatchProc ();
fdir->set_sensitive (true);
fformat->set_sensitive (true);
if (qsize == 0) {
SoundManager::playSoundAsync(options.sndBatchQueueDone);
}
}
if (queueError) {
Gtk::MessageDialog msgd (queueErrorMessage, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);