Convert BatchQueue::cancelItems()
to functional IdleRegister::add()
This commit is contained in:
parent
b08fb04dae
commit
732bbf1a55
@ -86,6 +86,17 @@ BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCa
|
||||
|
||||
BatchQueue::~BatchQueue ()
|
||||
{
|
||||
std::set<BatchQueueEntry*> removable_bqes;
|
||||
|
||||
mutex_removable_batch_queue_entries.lock();
|
||||
removable_batch_queue_entries.swap(removable_bqes);
|
||||
mutex_removable_batch_queue_entries.unlock();
|
||||
|
||||
for (const auto entry : removable_bqes) {
|
||||
::g_remove(entry->savedParamsFile.c_str());
|
||||
delete entry;
|
||||
}
|
||||
|
||||
idle_register.destroy();
|
||||
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
@ -395,6 +406,8 @@ Glib::ustring BatchQueue::getTempFilenameForParams( const Glib::ustring &filenam
|
||||
|
||||
void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
{
|
||||
std::set<BatchQueueEntry*> removable_bqes;
|
||||
|
||||
{
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
|
||||
@ -417,14 +430,7 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
if (entry->thumbnail)
|
||||
entry->thumbnail->imageRemovedFromQueue ();
|
||||
|
||||
const auto func =
|
||||
[](BatchQueueEntry* bqe) -> bool
|
||||
{
|
||||
::g_remove(bqe->savedParamsFile.c_str());
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add<BatchQueueEntry>(func, entry, true);
|
||||
removable_bqes.insert(entry);
|
||||
}
|
||||
|
||||
for (const auto entry : fd)
|
||||
@ -434,6 +440,30 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
selected.clear ();
|
||||
}
|
||||
|
||||
if (!removable_bqes.empty()) {
|
||||
mutex_removable_batch_queue_entries.lock();
|
||||
removable_batch_queue_entries.insert(removable_bqes.begin(), removable_bqes.end());
|
||||
mutex_removable_batch_queue_entries.unlock();
|
||||
|
||||
idle_register.add(
|
||||
[this]() -> bool
|
||||
{
|
||||
std::set<BatchQueueEntry*> removable_bqes;
|
||||
|
||||
mutex_removable_batch_queue_entries.lock();
|
||||
removable_batch_queue_entries.swap(removable_bqes);
|
||||
mutex_removable_batch_queue_entries.unlock();
|
||||
|
||||
for (const auto entry : removable_bqes) {
|
||||
::g_remove(entry->savedParamsFile.c_str());
|
||||
delete entry;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
saveBatchQueue ();
|
||||
|
||||
redraw ();
|
||||
@ -940,9 +970,7 @@ Glib::ustring BatchQueue::autoCompleteFileName (const Glib::ustring& fileName, c
|
||||
|
||||
void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionData)
|
||||
{
|
||||
|
||||
std::vector<ThumbBrowserEntryBase*> bqe;
|
||||
bqe.push_back (static_cast<BatchQueueEntry*>(actionData));
|
||||
const std::vector<ThumbBrowserEntryBase*> bqe = {static_cast<BatchQueueEntry*>(actionData)};
|
||||
|
||||
if (actionCode == 10) { // cancel
|
||||
cancelItems (bqe);
|
||||
|
@ -18,12 +18,16 @@
|
||||
#ifndef _BATCHQUEUE_
|
||||
#define _BATCHQUEUE_
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "threadutils.h"
|
||||
#include "batchqueueentry.h"
|
||||
|
||||
#include "../rtengine/rtengine.h"
|
||||
#include "options.h"
|
||||
|
||||
#include "batchqueueentry.h"
|
||||
#include "lwbuttonset.h"
|
||||
#include "options.h"
|
||||
#include "threadutils.h"
|
||||
#include "thumbbrowserbase.h"
|
||||
|
||||
class BatchQueueListener
|
||||
@ -85,7 +89,7 @@ public:
|
||||
static Glib::ustring calcAutoFileNameBase (const Glib::ustring& origFileName, int sequence = 0);
|
||||
static int calcMaxThumbnailHeight();
|
||||
|
||||
protected:
|
||||
private:
|
||||
int getMaxThumbnailHeight() const override;
|
||||
void saveThumbnailHeight (int height) override;
|
||||
int getThumbnailHeight () override;
|
||||
@ -111,6 +115,9 @@ protected:
|
||||
|
||||
BatchQueueListener* listener;
|
||||
|
||||
std::set<BatchQueueEntry*> removable_batch_queue_entries;
|
||||
MyMutex mutex_removable_batch_queue_entries;
|
||||
|
||||
IdleRegister idle_register;
|
||||
};
|
||||
|
||||
|
@ -930,7 +930,7 @@ void FileCatalog::filterApplied()
|
||||
|
||||
void FileCatalog::openRequested(const std::vector<Thumbnail*>& tmb)
|
||||
{
|
||||
for (auto thumb : tmb) {
|
||||
for (const auto thumb : tmb) {
|
||||
thumb->increaseRef();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user