Threading enhancements, cleanups
This commit is contained in:
@@ -64,7 +64,7 @@ void BatchQueue::addEntries ( std::vector<BatchQueueEntry*> &entries, bool head)
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for( std::vector<BatchQueueEntry*>::iterator entry = entries.begin(); entry != entries.end();entry++ ){
|
||||
@@ -127,7 +127,7 @@ void BatchQueue::loadBatchQueue( )
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
Glib::ustring savedQueueFile;
|
||||
@@ -222,7 +222,7 @@ void BatchQueue::cancelItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<items->size(); i++) {
|
||||
@@ -254,7 +254,7 @@ void BatchQueue::headItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
for (int i=items->size()-1; i>=0; i--) {
|
||||
BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i];
|
||||
@@ -281,7 +281,7 @@ void BatchQueue::tailItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
for (int i=0; i<items->size(); i++) {
|
||||
BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i];
|
||||
@@ -300,9 +300,10 @@ void BatchQueue::tailItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
}
|
||||
|
||||
void BatchQueue::selectAll () {
|
||||
{// TODO: Check for Linux
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
lastClicked = NULL;
|
||||
@@ -316,40 +317,36 @@ void BatchQueue::selectAll () {
|
||||
}
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
void BatchQueue::startProcessing () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
entryMutex.lock();
|
||||
#endif
|
||||
|
||||
if (!processing && fd.size()>0) {
|
||||
BatchQueueEntry* next = (BatchQueueEntry*)fd[0];
|
||||
// tag it as processing
|
||||
next->processing = true;
|
||||
processing = next;
|
||||
// remove from selection
|
||||
if (processing->selected) {
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator pos = std::find (selected.begin(), selected.end(), processing);
|
||||
if (pos!=selected.end())
|
||||
selected.erase (pos);
|
||||
processing->selected = false;
|
||||
BatchQueueEntry* next;
|
||||
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
next = (BatchQueueEntry*)fd[0];
|
||||
// tag it as processing
|
||||
next->processing = true;
|
||||
processing = next;
|
||||
// remove from selection
|
||||
if (processing->selected) {
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator pos = std::find (selected.begin(), selected.end(), processing);
|
||||
if (pos!=selected.end())
|
||||
selected.erase (pos);
|
||||
processing->selected = false;
|
||||
}
|
||||
|
||||
// remove button set
|
||||
next->removeButtonSet ();
|
||||
}
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
entryMutex.unlock();
|
||||
#endif
|
||||
|
||||
// remove button set
|
||||
next->removeButtonSet ();
|
||||
// start batch processing
|
||||
rtengine::startBatchProcessing (next->job, this, options.tunnelMetaData);
|
||||
queue_draw ();
|
||||
} else {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
entryMutex.unlock();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +402,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
fd.erase (fd.begin());
|
||||
|
||||
@@ -361,16 +361,16 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin();
|
||||
while (i!=fd.end() && *entry < *((FileBrowserEntry*)*i))
|
||||
i++;
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin();
|
||||
while (i!=fd.end() && *entry < *((FileBrowserEntry*)*i))
|
||||
i++;
|
||||
|
||||
fd.insert (i, entry);
|
||||
fd.insert (i, entry);
|
||||
|
||||
initEntry (entry);
|
||||
initEntry (entry);
|
||||
}
|
||||
redraw ();
|
||||
}
|
||||
@@ -378,7 +378,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) {
|
||||
FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (std::vector<ThumbBrowserEntryBase*>::iterator i=fd.begin(); i!=fd.end(); i++)
|
||||
@@ -387,13 +387,18 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
|
||||
entry->selected = false;
|
||||
fd.erase (i);
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), entry);
|
||||
|
||||
l.release();
|
||||
|
||||
if (j!=selected.end()) {
|
||||
selected.erase (j);
|
||||
notifySelectionListener ();
|
||||
}
|
||||
|
||||
if (lastClicked==entry)
|
||||
lastClicked = NULL;
|
||||
redraw ();
|
||||
|
||||
return (FileBrowserEntry*)entry;
|
||||
}
|
||||
return NULL;
|
||||
@@ -402,12 +407,13 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
|
||||
FileBrowserEntry* FileBrowser::findEntry (const Glib::ustring& fname) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (std::vector<ThumbBrowserEntryBase*>::iterator i=fd.begin(); i!=fd.end(); i++)
|
||||
if ((*i)->filename==fname)
|
||||
return (FileBrowserEntry*)*i;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -425,19 +431,18 @@ void FileBrowser::close () {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
|
||||
selected.clear ();
|
||||
notifySelectionListener ();
|
||||
|
||||
// The listener merges parameters with old values, so delete afterwards
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
{
|
||||
delete fd[i];
|
||||
}
|
||||
fd.clear ();
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
{
|
||||
delete fd[i];
|
||||
}
|
||||
fd.clear ();
|
||||
}
|
||||
|
||||
lastClicked = NULL;
|
||||
@@ -485,15 +490,15 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
selected.clear ();
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
if (checkFilter (fd[i])) {
|
||||
fd[i]->selected = true;
|
||||
selected.push_back (fd[i]);
|
||||
}
|
||||
selected.clear ();
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
if (checkFilter (fd[i])) {
|
||||
fd[i]->selected = true;
|
||||
selected.push_back (fd[i]);
|
||||
}
|
||||
}
|
||||
queue_draw ();
|
||||
notifySelectionListener ();
|
||||
@@ -750,19 +755,20 @@ void FileBrowser::applyFilter (const BrowserFilter& filter) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
if(checkFilter (fd[i]))
|
||||
numFiltered++;
|
||||
else if (fd[i]->selected ) {
|
||||
fd[i]->selected = false;
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), fd[i]);
|
||||
selected.erase (j);
|
||||
if (lastClicked==fd[i])
|
||||
lastClicked = NULL;
|
||||
selchanged = true;
|
||||
for (int i=0; i<fd.size(); i++) {
|
||||
if (checkFilter (fd[i]))
|
||||
numFiltered++;
|
||||
else if (fd[i]->selected ) {
|
||||
fd[i]->selected = false;
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), fd[i]);
|
||||
selected.erase (j);
|
||||
if (lastClicked==fd[i])
|
||||
lastClicked = NULL;
|
||||
selchanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -928,7 +934,7 @@ void FileBrowser::buttonPressed (LWButton* button, int actionCode, void* actionD
|
||||
void FileBrowser::openNextImage () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
if (fd.size()>0) {
|
||||
@@ -951,7 +957,7 @@ void FileBrowser::openNextImage () {
|
||||
void FileBrowser::openPrevImage () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
if (fd.size()>0) {
|
||||
|
||||
@@ -1233,14 +1233,14 @@ void FileCatalog::filterChanged () {
|
||||
_refreshProgressBar();
|
||||
}
|
||||
|
||||
int FileCatalog::reparseDirectory () {
|
||||
void FileCatalog::reparseDirectory () {
|
||||
|
||||
if (selectedDirectory=="")
|
||||
return 0;
|
||||
return;
|
||||
|
||||
if (!safe_file_test (selectedDirectory, Glib::FILE_TEST_IS_DIR)) {
|
||||
closeDir ();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> nfileNameList = getFileList ();
|
||||
@@ -1271,7 +1271,6 @@ int FileCatalog::reparseDirectory () {
|
||||
}
|
||||
|
||||
fileNameList = nfileNameList;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -204,7 +204,7 @@ class FileCatalog : public Gtk::VBox,
|
||||
|
||||
void on_realize();
|
||||
void on_dir_changed (const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<Gio::File>& other_file, Gio::FileMonitorEvent event_type, bool internal);
|
||||
int reparseDirectory ();
|
||||
void reparseDirectory ();
|
||||
void _openImage (std::vector<Thumbnail*> tmb);
|
||||
|
||||
void zoomIn ();
|
||||
|
||||
@@ -56,7 +56,7 @@ ThumbBrowserBase::ThumbBrowserBase ()
|
||||
void ThumbBrowserBase::scrollChanged () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@@ -139,7 +139,7 @@ void ThumbBrowserBase::configScrollBars () {
|
||||
void ThumbBrowserBase::arrangeFiles () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
int N = fd.size ();
|
||||
@@ -259,7 +259,7 @@ void ThumbBrowserBase::Internal::on_realize()
|
||||
bool ThumbBrowserBase::Internal::on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
Glib::ustring ttip = "";
|
||||
@@ -322,7 +322,7 @@ void ThumbBrowserBase::buttonPressed (int x, int y, int button, GdkEventType typ
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@@ -429,7 +429,7 @@ bool ThumbBrowserBase::Internal::on_expose_event(GdkEventExpose* event) {
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
int w = get_width();
|
||||
@@ -455,7 +455,7 @@ bool ThumbBrowserBase::Internal::on_button_release_event (GdkEventButton* event)
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
int w = get_width();
|
||||
@@ -470,7 +470,7 @@ bool ThumbBrowserBase::Internal::on_button_release_event (GdkEventButton* event)
|
||||
bool ThumbBrowserBase::Internal::on_motion_notify_event (GdkEventMotion* event) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
int w = get_width();
|
||||
@@ -518,7 +518,7 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++) fd[i]->resize (previewHeight);
|
||||
@@ -536,13 +536,11 @@ void ThumbBrowserBase::refreshThumbImages () {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
int previewHeight = getCurrentThumbSize();
|
||||
for (int i=0; i<fd.size(); i++){
|
||||
fd[i]->resize (previewHeight);// TODO!!! Might be performance bottleneck
|
||||
}
|
||||
for (int i=0; i<fd.size(); i++) fd[i]->resize (previewHeight);// TODO!!! Might be performance bottleneck
|
||||
}
|
||||
|
||||
redraw ();
|
||||
@@ -551,12 +549,10 @@ void ThumbBrowserBase::refreshThumbImages () {
|
||||
void ThumbBrowserBase::refreshQuickThumbImages () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); ++i){
|
||||
fd[i]->refreshQuickThumbnailImage ();
|
||||
}
|
||||
for (int i=0; i<fd.size(); ++i) fd[i]->refreshQuickThumbnailImage ();
|
||||
}
|
||||
|
||||
void ThumbBrowserBase::refreshEditedState (const std::set<Glib::ustring>& efiles) {
|
||||
@@ -565,7 +561,7 @@ void ThumbBrowserBase::refreshEditedState (const std::set<Glib::ustring>& efiles
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@@ -589,7 +585,7 @@ void ThumbBrowserBase::enableTabMode(bool enable) {
|
||||
if (options.thumbSizeTab!=options.thumbSize) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@@ -634,7 +630,7 @@ int ThumbBrowserBase::getEffectiveHeight() {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
// Filtered items do not change in size, so take a non-filtered
|
||||
|
||||
@@ -75,8 +75,7 @@ class ThumbBrowserBase : public Gtk::VBox {
|
||||
|
||||
int eventTime;
|
||||
|
||||
Glib::Mutex entryMutex; // Locks access to following vectors
|
||||
|
||||
Glib::RWLock entryRW; // Locks access to following vectors
|
||||
std::vector<ThumbBrowserEntryBase*> fd;
|
||||
std::vector<ThumbBrowserEntryBase*> selected;
|
||||
ThumbBrowserEntryBase* lastClicked;
|
||||
|
||||
Reference in New Issue
Block a user