Merge pull request #4902 from thirtythreeforty/fix-batch-gui-notify
Fix GUI/batch state synchronization
This commit is contained in:
@@ -229,7 +229,7 @@ void BatchQueue::addEntries (const std::vector<BatchQueueEntry*>& entries, bool
|
|||||||
saveBatchQueue ();
|
saveBatchQueue ();
|
||||||
|
|
||||||
redraw ();
|
redraw ();
|
||||||
notifyListener (true);
|
notifyListener ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BatchQueue::saveBatchQueue ()
|
bool BatchQueue::saveBatchQueue ()
|
||||||
@@ -387,7 +387,7 @@ bool BatchQueue::loadBatchQueue ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
redraw ();
|
redraw ();
|
||||||
notifyListener (true);
|
notifyListener ();
|
||||||
|
|
||||||
return !fd.empty ();
|
return !fd.empty ();
|
||||||
}
|
}
|
||||||
@@ -460,7 +460,7 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
|||||||
saveBatchQueue ();
|
saveBatchQueue ();
|
||||||
|
|
||||||
redraw ();
|
redraw ();
|
||||||
notifyListener (true);
|
notifyListener ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||||
@@ -597,6 +597,8 @@ void BatchQueue::startProcessing ()
|
|||||||
// start batch processing
|
// start batch processing
|
||||||
rtengine::startBatchProcessing (next->job, this);
|
rtengine::startBatchProcessing (next->job, this);
|
||||||
queue_draw ();
|
queue_draw ();
|
||||||
|
|
||||||
|
notifyListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -775,8 +777,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
|
|||||||
}
|
}
|
||||||
|
|
||||||
redraw ();
|
redraw ();
|
||||||
const bool queueRunning = processing;
|
notifyListener ();
|
||||||
notifyListener (queueRunning);
|
|
||||||
|
|
||||||
return processing ? processing->job : nullptr;
|
return processing ? processing->job : nullptr;
|
||||||
}
|
}
|
||||||
@@ -971,9 +972,9 @@ void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionDa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchQueue::notifyListener (bool queueRunning)
|
void BatchQueue::notifyListener ()
|
||||||
{
|
{
|
||||||
|
const bool queueRunning = processing;
|
||||||
if (listener) {
|
if (listener) {
|
||||||
NLParams* params = new NLParams;
|
NLParams* params = new NLParams;
|
||||||
params->listener = listener;
|
params->listener = listener;
|
||||||
|
@@ -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 queueRunning);
|
void notifyListener ();
|
||||||
|
|
||||||
BatchQueueEntry* processing; // holds the currently processed image
|
BatchQueueEntry* processing; // holds the currently processed image
|
||||||
FileCatalog* fileCatalog;
|
FileCatalog* fileCatalog;
|
||||||
|
@@ -247,23 +247,14 @@ void BatchQueuePanel::updateTab (int qsize, int forceOrientation)
|
|||||||
|
|
||||||
void BatchQueuePanel::queueSizeChanged(int qsize, bool queueRunning, bool queueError, const Glib::ustring& queueErrorMessage)
|
void BatchQueuePanel::queueSizeChanged(int qsize, bool queueRunning, bool queueError, const Glib::ustring& queueErrorMessage)
|
||||||
{
|
{
|
||||||
updateTab (qsize);
|
setGuiFromBatchState(queueRunning, qsize);
|
||||||
|
|
||||||
if (qsize == 0 || (qsize == 1 && queueRunning)) {
|
if (!queueRunning && qsize == 0 && queueShouldRun) {
|
||||||
qStartStop->set_sensitive(false);
|
// There was work, but it is all done now.
|
||||||
} else {
|
queueShouldRun = false;
|
||||||
qStartStop->set_sensitive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!queueRunning) {
|
|
||||||
stopBatchProc ();
|
|
||||||
fdir->set_sensitive (true);
|
|
||||||
fformat->set_sensitive (true);
|
|
||||||
|
|
||||||
if (qsize == 0) {
|
|
||||||
SoundManager::playSoundAsync(options.sndBatchQueueDone);
|
SoundManager::playSoundAsync(options.sndBatchQueueDone);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (queueError) {
|
if (queueError) {
|
||||||
Gtk::MessageDialog msgd (queueErrorMessage, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
Gtk::MessageDialog msgd (queueErrorMessage, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
@@ -273,8 +264,7 @@ void BatchQueuePanel::queueSizeChanged(int qsize, bool queueRunning, bool queueE
|
|||||||
|
|
||||||
void BatchQueuePanel::startOrStopBatchProc()
|
void BatchQueuePanel::startOrStopBatchProc()
|
||||||
{
|
{
|
||||||
bool state = qStartStop->get_state();
|
if (qStartStop->get_state()) {
|
||||||
if (state) {
|
|
||||||
startBatchProc();
|
startBatchProc();
|
||||||
} else {
|
} else {
|
||||||
stopBatchProc();
|
stopBatchProc();
|
||||||
@@ -283,36 +273,42 @@ void BatchQueuePanel::startOrStopBatchProc()
|
|||||||
|
|
||||||
void BatchQueuePanel::startBatchProc ()
|
void BatchQueuePanel::startBatchProc ()
|
||||||
{
|
{
|
||||||
// Update switch when queue started programmatically
|
|
||||||
qStartStopConn.block (true);
|
|
||||||
qStartStop->set_active(true);
|
|
||||||
qStartStopState = true;
|
|
||||||
qStartStopConn.block (false);
|
|
||||||
|
|
||||||
if (batchQueue->hasJobs()) {
|
if (batchQueue->hasJobs()) {
|
||||||
fdir->set_sensitive (false);
|
// Update the *desired* state of the queue, then launch it. The switch
|
||||||
fformat->set_sensitive (false);
|
// state is not updated here; it is changed by the queueSizeChanged()
|
||||||
if (batchQueue->getEntries().size() == 1) {
|
// callback in response to the *reported* state.
|
||||||
qStartStop->set_sensitive(false);
|
queueShouldRun = true;
|
||||||
}
|
|
||||||
saveOptions();
|
saveOptions();
|
||||||
batchQueue->startProcessing ();
|
batchQueue->startProcessing ();
|
||||||
} else {
|
|
||||||
stopBatchProc ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTab (batchQueue->getEntries().size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchQueuePanel::stopBatchProc ()
|
void BatchQueuePanel::stopBatchProc ()
|
||||||
{
|
{
|
||||||
// Update switch when queue started programmatically
|
// There is nothing much to do here except set the desired state, which the
|
||||||
|
// background queue thread must check. It will notify queueSizeChanged()
|
||||||
|
// when it stops.
|
||||||
|
queueShouldRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BatchQueuePanel::setGuiFromBatchState(bool queueRunning, int qsize)
|
||||||
|
{
|
||||||
|
// Change the GUI state in response to the reported queue state
|
||||||
|
if (qsize == 0 || (qsize == 1 && queueRunning)) {
|
||||||
|
qStartStop->set_sensitive(false);
|
||||||
|
} else {
|
||||||
|
qStartStop->set_sensitive(true);
|
||||||
|
}
|
||||||
|
|
||||||
qStartStopConn.block(true);
|
qStartStopConn.block(true);
|
||||||
qStartStop->set_active(false);
|
qStartStop->set_active(queueRunning);
|
||||||
qStartStopState = false;
|
|
||||||
qStartStopConn.block(false);
|
qStartStopConn.block(false);
|
||||||
|
|
||||||
updateTab (batchQueue->getEntries().size());
|
fdir->set_sensitive (!queueRunning);
|
||||||
|
fformat->set_sensitive (!queueRunning);
|
||||||
|
|
||||||
|
updateTab(qsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchQueuePanel::addBatchQueueJobs(const std::vector<BatchQueueEntry*>& entries, bool head)
|
void BatchQueuePanel::addBatchQueueJobs(const std::vector<BatchQueueEntry*>& entries, bool head)
|
||||||
@@ -320,6 +316,7 @@ void BatchQueuePanel::addBatchQueueJobs(const std::vector<BatchQueueEntry*>& ent
|
|||||||
batchQueue->addEntries(entries, head);
|
batchQueue->addEntries(entries, head);
|
||||||
|
|
||||||
if (!qStartStop->get_active() && qAutoStart->get_active()) {
|
if (!qStartStop->get_active() && qAutoStart->get_active()) {
|
||||||
|
// Auto-start as if the user had pressed the qStartStop switch
|
||||||
startBatchProc ();
|
startBatchProc ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,9 +351,9 @@ bool BatchQueuePanel::handleShortcutKey (GdkEventKey* event)
|
|||||||
|
|
||||||
bool BatchQueuePanel::canStartNext ()
|
bool BatchQueuePanel::canStartNext ()
|
||||||
{
|
{
|
||||||
// This function is called from the background BatchQueue thread.
|
// This function is called from the background BatchQueue thread. It
|
||||||
// It cannot call UI functions, so grab the stored state of qStartStop.
|
// cannot call UI functions; we keep the desired state in an atomic.
|
||||||
return qStartStopState;
|
return queueShouldRun;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchQueuePanel::pathFolderButtonPressed ()
|
void BatchQueuePanel::pathFolderButtonPressed ()
|
||||||
|
@@ -53,7 +53,7 @@ class BatchQueuePanel : public Gtk::VBox,
|
|||||||
Gtk::HBox* bottomBox;
|
Gtk::HBox* bottomBox;
|
||||||
Gtk::HBox* topBox;
|
Gtk::HBox* topBox;
|
||||||
|
|
||||||
std::atomic<bool> qStartStopState;
|
std::atomic<bool> queueShouldRun;
|
||||||
|
|
||||||
IdleRegister idle_register;
|
IdleRegister idle_register;
|
||||||
|
|
||||||
@@ -76,6 +76,7 @@ private:
|
|||||||
void startBatchProc ();
|
void startBatchProc ();
|
||||||
void stopBatchProc ();
|
void stopBatchProc ();
|
||||||
void startOrStopBatchProc();
|
void startOrStopBatchProc();
|
||||||
|
void setGuiFromBatchState(bool queueRunning, int qsize);
|
||||||
|
|
||||||
void pathFolderChanged ();
|
void pathFolderChanged ();
|
||||||
void pathFolderButtonPressed ();
|
void pathFolderButtonPressed ();
|
||||||
|
Reference in New Issue
Block a user