Store qStartStop state in atomic for background thread

Closes #4882.
This commit is contained in:
George Hilliard
2018-10-26 00:53:39 -05:00
parent 7d5fe6d1c8
commit 09275b5826
2 changed files with 9 additions and 8 deletions

View File

@@ -286,6 +286,7 @@ void BatchQueuePanel::startBatchProc ()
// Update switch when queue started programmatically // Update switch when queue started programmatically
qStartStopConn.block (true); qStartStopConn.block (true);
qStartStop->set_active(true); qStartStop->set_active(true);
qStartStopState = true;
qStartStopConn.block (false); qStartStopConn.block (false);
if (batchQueue->hasJobs()) { if (batchQueue->hasJobs()) {
@@ -308,6 +309,7 @@ void BatchQueuePanel::stopBatchProc ()
// Update switch when queue started programmatically // Update switch when queue started programmatically
qStartStopConn.block (true); qStartStopConn.block (true);
qStartStop->set_active(false); qStartStop->set_active(false);
qStartStopState = false;
qStartStopConn.block (false); qStartStopConn.block (false);
updateTab (batchQueue->getEntries().size()); updateTab (batchQueue->getEntries().size());
@@ -324,14 +326,9 @@ void BatchQueuePanel::addBatchQueueJobs(const std::vector<BatchQueueEntry*>& ent
bool BatchQueuePanel::canStartNext () bool BatchQueuePanel::canStartNext ()
{ {
// GThreadLock lock; // This function is called from the background BatchQueue thread.
if (qStartStop->get_active()) { // It cannot call UI functions, so grab the stored state of qStartStop.
return true; return qStartStopState;
} else {
fdir->set_sensitive (true);
fformat->set_sensitive (true);
return false;
}
} }
void BatchQueuePanel::saveOptions () void BatchQueuePanel::saveOptions ()

View File

@@ -19,6 +19,8 @@
#ifndef _BATCHQUEUEPANEL_ #ifndef _BATCHQUEUEPANEL_
#define _BATCHQUEUEPANEL_ #define _BATCHQUEUEPANEL_
#include <atomic>
#include <gtkmm.h> #include <gtkmm.h>
#include "batchqueue.h" #include "batchqueue.h"
#include "saveformatpanel.h" #include "saveformatpanel.h"
@@ -53,6 +55,8 @@ class BatchQueuePanel : public Gtk::VBox,
IdleRegister idle_register; IdleRegister idle_register;
std::atomic<bool> qStartStopState;
public: public:
explicit BatchQueuePanel (FileCatalog* aFileCatalog); explicit BatchQueuePanel (FileCatalog* aFileCatalog);
~BatchQueuePanel(); ~BatchQueuePanel();