Remove PROTECT_VECTORS option since either program is correct without locking or it is not, especially since std::vector is definitely not thread-safe on all major platforms.
This commit is contained in:
parent
5883410354
commit
17d9309f1c
@ -99,7 +99,6 @@ option (WITH_BZIP "Build with Bzip2 support" ON)
|
||||
option (WITH_MYFILE_MMAP "Build using memory mapped file" ON)
|
||||
option (WITH_LTO "Build with link-time optimizations" OFF)
|
||||
option (OPTION_OMP "Build with OpenMP support" ON)
|
||||
option (PROTECT_VECTORS "Protect critical vectors by custom R/W Mutex, recommanded even if your std::vector is thread safe" ON)
|
||||
option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON)
|
||||
option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF)
|
||||
option (AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF)
|
||||
@ -204,13 +203,7 @@ else (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
endif (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
|
||||
# MyRWMutex
|
||||
if (PROTECT_VECTORS)
|
||||
add_definitions (-DPROTECT_VECTORS=1)
|
||||
else (PROTECT_VECTORS)
|
||||
add_definitions (-DPROTECT_VECTORS=0)
|
||||
endif (PROTECT_VECTORS)
|
||||
if (TRACE_MYRWMUTEX)
|
||||
# Note: it will be set to 0 for Debug builds (rtgui/guiutils.h)
|
||||
add_definitions (-DTRACE_MYRWMUTEX=1)
|
||||
else (TRACE_MYRWMUTEX)
|
||||
add_definitions (-DTRACE_MYRWMUTEX=0)
|
||||
|
@ -90,9 +90,7 @@ BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(NULL), fileCatal
|
||||
|
||||
BatchQueue::~BatchQueue ()
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
// The listener merges parameters with old values, so delete afterwards
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
@ -104,9 +102,7 @@ BatchQueue::~BatchQueue ()
|
||||
|
||||
void BatchQueue::resizeLoadedQueue()
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
const auto height = getThumbnailHeight ();
|
||||
|
||||
@ -175,9 +171,7 @@ bool BatchQueue::keyPressed (GdkEventKey* event)
|
||||
void BatchQueue::addEntries (const std::vector<BatchQueueEntry*>& entries, bool head, bool save)
|
||||
{
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (const auto entry : entries) {
|
||||
|
||||
@ -229,9 +223,8 @@ bool BatchQueue::saveBatchQueue ()
|
||||
return false;
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (fd.empty ())
|
||||
return true;
|
||||
|
||||
@ -268,9 +261,7 @@ bool BatchQueue::loadBatchQueue ()
|
||||
if (file.is_open ()) {
|
||||
// Yes, it's better to get the lock for the whole file reading,
|
||||
// to update the list in one shot without any other concurrent access!
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
std::string row, column;
|
||||
std::vector<std::string> values;
|
||||
@ -402,9 +393,7 @@ int cancelItemUI (void* data)
|
||||
void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
{
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (const auto item : items) {
|
||||
|
||||
@ -444,9 +433,8 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
{
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (auto item = items.rbegin(); item != items.rend(); ++item) {
|
||||
|
||||
const auto entry = static_cast<BatchQueueEntry*> (*item);
|
||||
@ -476,9 +464,7 @@ void BatchQueue::headItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
void BatchQueue::tailItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
{
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (const auto item : items) {
|
||||
|
||||
@ -506,10 +492,7 @@ void BatchQueue::tailItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
void BatchQueue::selectAll ()
|
||||
{
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
lastClicked = NULL;
|
||||
selected.clear ();
|
||||
@ -529,10 +512,7 @@ void BatchQueue::selectAll ()
|
||||
void BatchQueue::openLastSelectedItemInEditor()
|
||||
{
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (selected.size() > 0) {
|
||||
openItemInEditor(selected.back());
|
||||
@ -554,10 +534,7 @@ void BatchQueue::startProcessing ()
|
||||
{
|
||||
|
||||
if (!processing) {
|
||||
// TODO: Check for Linux
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!fd.empty()) {
|
||||
BatchQueueEntry* next;
|
||||
@ -579,9 +556,7 @@ void BatchQueue::startProcessing ()
|
||||
processing->selected = false;
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
// remove button set
|
||||
next->removeButtonSet ();
|
||||
@ -657,10 +632,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img)
|
||||
bool remove_button_set = false;
|
||||
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
delete processing;
|
||||
processing = NULL;
|
||||
@ -704,15 +676,11 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img)
|
||||
// Delete all files in directory \batch when finished, just to be sure to remove zombies
|
||||
|
||||
// Not sure that locking is necessary, but it should be safer
|
||||
// TODO: Check for Linux
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if( fd.empty() ) {
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
std::vector<Glib::ustring> names;
|
||||
Glib::ustring batchdir = Glib::build_filename(options.rtdir, "batch");
|
||||
Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path (batchdir);
|
||||
@ -955,10 +923,7 @@ void BatchQueue::notifyListener (bool queueEmptied)
|
||||
NLParams* params = new NLParams;
|
||||
params->listener = listener;
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
params->qsize = fd.size();
|
||||
}
|
||||
params->queueEmptied = queueEmptied;
|
||||
|
@ -83,11 +83,7 @@ public:
|
||||
|
||||
bool hasJobs ()
|
||||
{
|
||||
// not sure that this lock is necessary, but it's safer to keep it...
|
||||
// TODO: Check for Linux
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
return (!fd.empty());
|
||||
}
|
||||
|
||||
|
@ -244,10 +244,7 @@ void BatchQueueEntry::_updateImage (guint8* img, int w, int h)
|
||||
{
|
||||
|
||||
if (preh == h) {
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, lockRW);
|
||||
#endif
|
||||
|
||||
prew = w;
|
||||
assert (preview == NULL);
|
||||
|
@ -222,7 +222,7 @@ FileBrowser::FileBrowser ()
|
||||
/***********************
|
||||
* external programs
|
||||
* *********************/
|
||||
#if defined(WIN32) && defined(PROTECT_VECTORS)
|
||||
#if defined(WIN32)
|
||||
Gtk::manage(miOpenDefaultViewer = new Gtk::MenuItem (M("FILEBROWSER_OPENDEFAULTVIEWER")));
|
||||
#else
|
||||
miOpenDefaultViewer = NULL;
|
||||
@ -483,9 +483,7 @@ void FileBrowser::rightClicked (ThumbBrowserEntryBase* entry)
|
||||
{
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
trash->set_sensitive (false);
|
||||
untrash->set_sensitive (false);
|
||||
@ -622,9 +620,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry)
|
||||
|
||||
// find place in abc order
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin();
|
||||
|
||||
@ -644,9 +640,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry)
|
||||
|
||||
FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname)
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin(); i != fd.end(); i++)
|
||||
if ((*i)->filename == fname) {
|
||||
@ -655,9 +649,7 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname)
|
||||
fd.erase (i);
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), entry);
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
if (j != selected.end()) {
|
||||
if (checkFilter (*j)) {
|
||||
@ -694,21 +686,15 @@ void FileBrowser::close ()
|
||||
fbih->pending = 0;
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
selected.clear ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l); // notifySelectionListener will need read access!
|
||||
#endif
|
||||
|
||||
notifySelectionListener ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_ACQUIRE(l);
|
||||
#endif
|
||||
|
||||
// The listener merges parameters with old values, so delete afterwards
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
@ -740,9 +726,7 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m)
|
||||
std::vector<FileBrowserEntry*> mselected;
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < selected.size(); i++) {
|
||||
mselected.push_back (static_cast<FileBrowserEntry*>(selected[i]));
|
||||
@ -812,9 +796,7 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m)
|
||||
} else if (m == selall) {
|
||||
lastClicked = NULL;
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
selected.clear ();
|
||||
|
||||
@ -1034,9 +1016,7 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m)
|
||||
|
||||
void FileBrowser::copyProfile ()
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (selected.size() == 1) {
|
||||
clipboard.setProcParams ((static_cast<FileBrowserEntry*>(selected[0]))->thumbnail->getProcParams());
|
||||
@ -1049,9 +1029,7 @@ void FileBrowser::pasteProfile ()
|
||||
if (clipboard.hasProcParams()) {
|
||||
std::vector<FileBrowserEntry*> mselected;
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (unsigned int i = 0; i < selected.size(); i++) {
|
||||
mselected.push_back (static_cast<FileBrowserEntry*>(selected[i]));
|
||||
@ -1091,9 +1069,7 @@ void FileBrowser::partPasteProfile ()
|
||||
|
||||
std::vector<FileBrowserEntry*> mselected;
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (unsigned int i = 0; i < selected.size(); i++) {
|
||||
mselected.push_back (static_cast<FileBrowserEntry*>(selected[i]));
|
||||
@ -1142,9 +1118,7 @@ void FileBrowser::openDefaultViewer (int destination)
|
||||
bool success = true;
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (selected.size() == 1) {
|
||||
success = (static_cast<FileBrowserEntry*>(selected[0]))->thumbnail->openDefaultViewer(destination);
|
||||
@ -1378,10 +1352,7 @@ int FileBrowser::getThumbnailHeight ()
|
||||
|
||||
void FileBrowser::applyMenuItemActivated (ProfileStoreLabel *label)
|
||||
{
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
const rtengine::procparams::PartialProfile* partProfile = profileStore.getProfile (label->entry);
|
||||
|
||||
@ -1406,9 +1377,7 @@ void FileBrowser::applyPartialMenuItemActivated (ProfileStoreLabel *label)
|
||||
{
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!tbl || selected.empty()) {
|
||||
return;
|
||||
@ -1420,9 +1389,7 @@ void FileBrowser::applyPartialMenuItemActivated (ProfileStoreLabel *label)
|
||||
if (srcProfiles->pparams) {
|
||||
if (partialPasteDlg.run() == Gtk::RESPONSE_OK) {
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (bppcl) {
|
||||
bppcl->beginBatchPParamsChange(selected.size());
|
||||
@ -1459,9 +1426,7 @@ void FileBrowser::applyFilter (const BrowserFilter& filter)
|
||||
bool selchanged = false;
|
||||
numFiltered = 0;
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW); // Don't make this a writer lock! HOMBRE: Why? 'selected' is modified here
|
||||
#endif
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
|
||||
if (filter.showOriginal) {
|
||||
findOriginalEntries(fd);
|
||||
@ -1712,9 +1677,7 @@ void FileBrowser::requestRanking(int rank)
|
||||
{
|
||||
std::vector<FileBrowserEntry*> mselected;
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < selected.size(); i++) {
|
||||
mselected.push_back (static_cast<FileBrowserEntry*>(selected[i]));
|
||||
@ -1728,9 +1691,7 @@ void FileBrowser::requestColorLabel(int colorlabel)
|
||||
{
|
||||
std::vector<FileBrowserEntry*> mselected;
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < selected.size(); i++) {
|
||||
mselected.push_back (static_cast<FileBrowserEntry*>(selected[i]));
|
||||
@ -1770,9 +1731,7 @@ void FileBrowser::buttonPressed (LWButton* button, int actionCode, void* actionD
|
||||
|
||||
void FileBrowser::openNextImage ()
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!fd.empty() && selected.size() > 0 && !options.tabbedUI) {
|
||||
|
||||
@ -1794,16 +1753,12 @@ void FileBrowser::openNextImage ()
|
||||
selected.push_back (fd[k]);
|
||||
//queue_draw ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
// this will require a read access
|
||||
notifySelectionListener ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_ACQUIRE(l);
|
||||
#endif
|
||||
|
||||
// scroll to the selected position
|
||||
double h1, v1;
|
||||
@ -1815,9 +1770,7 @@ void FileBrowser::openNextImage ()
|
||||
Thumbnail* thumb = (static_cast<FileBrowserEntry*>(fd[k]))->thumbnail;
|
||||
int minWidth = get_width() - fd[k]->getMinimalWidth();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
// scroll only when selected[0] is outside of the displayed bounds
|
||||
if (h2 + minWidth - h1 > get_width()) {
|
||||
@ -1843,9 +1796,7 @@ void FileBrowser::openNextImage ()
|
||||
|
||||
void FileBrowser::openPrevImage ()
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!fd.empty() && selected.size() > 0 && !options.tabbedUI) {
|
||||
|
||||
@ -1867,16 +1818,12 @@ void FileBrowser::openPrevImage ()
|
||||
selected.push_back (fd[k]);
|
||||
//queue_draw ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
// this will require a read access
|
||||
notifySelectionListener ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_ACQUIRE(l);
|
||||
#endif
|
||||
|
||||
// scroll to the selected position
|
||||
double h1, v1;
|
||||
@ -1888,9 +1835,7 @@ void FileBrowser::openPrevImage ()
|
||||
Thumbnail* thumb = (static_cast<FileBrowserEntry*>(fd[k]))->thumbnail;
|
||||
int minWidth = get_width() - fd[k]->getMinimalWidth();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
// scroll only when selected[0] is outside of the displayed bounds
|
||||
if (h2 + minWidth - h1 > get_width()) {
|
||||
@ -1919,10 +1864,7 @@ void FileBrowser::selectImage (Glib::ustring fname)
|
||||
{
|
||||
|
||||
// need to clear the filter in filecatalog
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!fd.empty() && !options.tabbedUI) {
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
@ -1941,24 +1883,18 @@ void FileBrowser::selectImage (Glib::ustring fname)
|
||||
selected.push_back (fd[i]);
|
||||
queue_draw ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
// this will require a read access
|
||||
notifySelectionListener ();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_ACQUIRE(l);
|
||||
#endif
|
||||
|
||||
// scroll to the selected position
|
||||
double h = selected[0]->getStartX();
|
||||
double v = selected[0]->getStartY();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
|
||||
setScrollPosition(h, v);
|
||||
|
||||
@ -2009,9 +1945,7 @@ void FileBrowser::notifySelectionListener ()
|
||||
{
|
||||
|
||||
if (tbl) {
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
std::vector<Thumbnail*> thm;
|
||||
|
||||
|
@ -236,10 +236,7 @@ void FileBrowserEntry::updateImage (rtengine::IImage8* img, double scale, rtengi
|
||||
|
||||
void FileBrowserEntry::_updateImage (rtengine::IImage8* img, double s, rtengine::procparams::CropParams cropParams)
|
||||
{
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, lockRW);
|
||||
#endif
|
||||
|
||||
redrawRequests--;
|
||||
scale = s;
|
||||
|
@ -20,8 +20,6 @@
|
||||
#define _THREADUTILS_
|
||||
|
||||
// Uncomment this if you want to bypass the CMakeList options and force the values, but do not commit!
|
||||
//#undef PROTECT_VECTORS
|
||||
//#define PROTECT_VECTORS 1
|
||||
//#undef TRACE_MYRWMUTEX
|
||||
//#define TRACE_MYRWMUTEX 1
|
||||
//#undef STRICT_MUTEX
|
||||
@ -319,20 +317,4 @@ inline MyWriterLock::~MyWriterLock ()
|
||||
#define MYWRITERLOCK_RELEASE(ln) ln.release();
|
||||
#endif
|
||||
|
||||
#ifdef PROTECT_VECTORS
|
||||
#define IFPV_MYREADERLOCK(l, e) MYREADERLOCK(l, e)
|
||||
#define IFPV_MYWRITERLOCK(l, e) MYWRITERLOCK(l, e)
|
||||
#define IFPV_MYREADERLOCK_ACQUIRE(l) MYREADERLOCK_ACQUIRE(l)
|
||||
#define IFPV_MYWRITERLOCK_ACQUIRE(l) MYWRITERLOCK_ACQUIRE(l)
|
||||
#define IFPV_MYREADERLOCK_RELEASE(l) MYREADERLOCK_RELEASE(l)
|
||||
#define IFPV_MYWRITERLOCK_RELEASE(l) MYWRITERLOCK_RELEASE(l)
|
||||
#else
|
||||
#define IFPV_MYREADERLOCK(l, e)
|
||||
#define IFPV_MYWRITERLOCK(l, e)
|
||||
#define IFPV_MYREADERLOCK_ACQUIRE(l)
|
||||
#define IFPV_MYWRITERLOCK_ACQUIRE(l)
|
||||
#define IFPV_MYREADERLOCK_RELEASE(l)
|
||||
#define IFPV_MYWRITERLOCK_RELEASE(l)
|
||||
#endif
|
||||
|
||||
#endif /* _THREADUTILS_ */
|
||||
|
@ -61,9 +61,7 @@ ThumbBrowserBase::ThumbBrowserBase ()
|
||||
void ThumbBrowserBase::scrollChanged ()
|
||||
{
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
fd[i]->setOffset ((int)(hscroll.get_value()), (int)(vscroll.get_value()));
|
||||
@ -206,9 +204,7 @@ void ThumbBrowserBase::selectPrev (int distance, bool enlarge)
|
||||
getScrollPosition (h, v);
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!selected.empty ()) {
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator front = std::find (fd.begin (), fd.end (), selected.front ());
|
||||
@ -263,9 +259,7 @@ void ThumbBrowserBase::selectPrev (int distance, bool enlarge)
|
||||
}
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
selectionChanged ();
|
||||
}
|
||||
|
||||
@ -278,9 +272,7 @@ void ThumbBrowserBase::selectNext (int distance, bool enlarge)
|
||||
getScrollPosition (h, v);
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!selected.empty ()) {
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator front = std::find (fd.begin (), fd.end (), selected.front ());
|
||||
@ -335,9 +327,7 @@ void ThumbBrowserBase::selectNext (int distance, bool enlarge)
|
||||
}
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
selectionChanged ();
|
||||
}
|
||||
|
||||
@ -350,9 +340,7 @@ void ThumbBrowserBase::selectFirst (bool enlarge)
|
||||
getScrollPosition (h, v);
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!fd.empty ()) {
|
||||
// find first unfiltered entry
|
||||
@ -403,9 +391,7 @@ void ThumbBrowserBase::selectFirst (bool enlarge)
|
||||
}
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
selectionChanged ();
|
||||
}
|
||||
|
||||
@ -418,9 +404,7 @@ void ThumbBrowserBase::selectLast (bool enlarge)
|
||||
getScrollPosition (h, v);
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!fd.empty ()) {
|
||||
// find last unfiltered entry
|
||||
@ -473,9 +457,7 @@ void ThumbBrowserBase::selectLast (bool enlarge)
|
||||
}
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
#endif
|
||||
selectionChanged ();
|
||||
}
|
||||
|
||||
@ -546,10 +528,7 @@ void ThumbBrowserBase::configScrollBars ()
|
||||
|
||||
void ThumbBrowserBase::arrangeFiles ()
|
||||
{
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
// GUI already locked by ::redraw, the only caller of this method for now.
|
||||
// We could lock it one more time, there's no harm excepted (negligible) speed penalty
|
||||
@ -610,9 +589,7 @@ void ThumbBrowserBase::arrangeFiles ()
|
||||
currx += maxw;
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK_RELEASE(l);
|
||||
#endif
|
||||
// This will require a Writer access
|
||||
resizeThumbnailArea (currx, numOfRows * rowHeight);
|
||||
} else {
|
||||
@ -689,9 +666,7 @@ void ThumbBrowserBase::arrangeFiles ()
|
||||
}
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK_RELEASE(l);
|
||||
#endif
|
||||
// This will require a Writer access
|
||||
resizeThumbnailArea (colsWidth, curry);
|
||||
}
|
||||
@ -733,9 +708,7 @@ bool ThumbBrowserBase::Internal::on_query_tooltip (int x, int y, bool keyboard_t
|
||||
Glib::ustring ttip = "";
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, parent->entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < parent->fd.size(); i++)
|
||||
if (parent->fd[i]->drawable && parent->fd[i]->inside (x, y)) {
|
||||
@ -808,7 +781,7 @@ void ThumbBrowserBase::buttonPressed (int x, int y, int button, GdkEventType typ
|
||||
bool handled = false;
|
||||
|
||||
{
|
||||
IFPV_MYREADERLOCK(l, entryRW);
|
||||
MYREADERLOCK(l, entryRW);
|
||||
|
||||
for (size_t i = 0; i < fd.size(); i++)
|
||||
if (fd[i]->drawable) {
|
||||
@ -826,7 +799,7 @@ void ThumbBrowserBase::buttonPressed (int x, int y, int button, GdkEventType typ
|
||||
}
|
||||
|
||||
{
|
||||
IFPV_MYWRITERLOCK(l, entryRW);
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
|
||||
if (selected.size() == 1 && type == GDK_2BUTTON_PRESS && button == 1) {
|
||||
doubleClicked (selected[0]);
|
||||
@ -839,18 +812,18 @@ void ThumbBrowserBase::buttonPressed (int x, int y, int button, GdkEventType typ
|
||||
selectSingle (fileDescr);
|
||||
|
||||
lastClicked = fileDescr;
|
||||
IFPV_MYWRITERLOCK_RELEASE(l);
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
selectionChanged ();
|
||||
} else if (fileDescr && button == 3 && type == GDK_BUTTON_PRESS) {
|
||||
if (!fileDescr->selected) {
|
||||
selectSingle (fileDescr);
|
||||
|
||||
lastClicked = fileDescr;
|
||||
IFPV_MYWRITERLOCK_RELEASE(l);
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
selectionChanged ();
|
||||
}
|
||||
|
||||
IFPV_MYWRITERLOCK_RELEASE(l);
|
||||
MYWRITERLOCK_RELEASE(l);
|
||||
rightClicked (fileDescr);
|
||||
}
|
||||
} // end of MYWRITERLOCK(l, entryRW);
|
||||
@ -874,9 +847,7 @@ bool ThumbBrowserBase::Internal::on_expose_event(GdkEventExpose* event)
|
||||
context->set_font_description (get_style()->get_font());
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, parent->entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < parent->fd.size() && !dirty; i++) { // if dirty meanwhile, cancel and wait for next redraw
|
||||
if (!parent->fd[i]->drawable || !parent->fd[i]->insideWindow (0, 0, w, h)) {
|
||||
@ -897,21 +868,15 @@ bool ThumbBrowserBase::Internal::on_button_release_event (GdkEventButton* event)
|
||||
int w = get_width();
|
||||
int h = get_height();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, parent->entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < parent->fd.size(); i++)
|
||||
if (parent->fd[i]->drawable && parent->fd[i]->insideWindow (0, 0, w, h)) {
|
||||
ThumbBrowserEntryBase* tbe = parent->fd[i];
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK_RELEASE(l);
|
||||
#endif
|
||||
// This will require a Writer access...
|
||||
tbe->releaseNotify (event->button, event->type, event->state, (int)event->x, (int)event->y);
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK_ACQUIRE(l);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -923,15 +888,10 @@ bool ThumbBrowserBase::Internal::on_motion_notify_event (GdkEventMotion* event)
|
||||
int w = get_width();
|
||||
int h = get_height();
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, parent->entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < parent->fd.size(); i++)
|
||||
if (parent->fd[i]->drawable && parent->fd[i]->insideWindow (0, 0, w, h)) {
|
||||
/*#if PROTECT_VECTORS
|
||||
MYREADERLOCK_RELEASE(l); // motionNotify calls the queue, which locks
|
||||
#endif*/
|
||||
parent->fd[i]->motionNotify ((int)event->x, (int)event->y);
|
||||
}
|
||||
|
||||
@ -983,9 +943,7 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn)
|
||||
saveThumbnailHeight(newHeight);
|
||||
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
fd[i]->resize (previewHeight);
|
||||
@ -1003,9 +961,7 @@ void ThumbBrowserBase::refreshThumbImages ()
|
||||
|
||||
int previewHeight = getThumbnailHeight();
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
fd[i]->resize (previewHeight);
|
||||
@ -1017,9 +973,7 @@ void ThumbBrowserBase::refreshThumbImages ()
|
||||
|
||||
void ThumbBrowserBase::refreshQuickThumbImages ()
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < fd.size(); ++i) {
|
||||
fd[i]->refreshQuickThumbnailImage ();
|
||||
@ -1031,9 +985,7 @@ void ThumbBrowserBase::refreshEditedState (const std::set<Glib::ustring>& efiles
|
||||
|
||||
editedFiles = efiles;
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
fd[i]->framed = editedFiles.find (fd[i]->filename) != editedFiles.end();
|
||||
@ -1056,9 +1008,8 @@ void ThumbBrowserBase::enableTabMode(bool enable)
|
||||
arrangement = enable ? ThumbBrowserBase::TB_Horizontal : ThumbBrowserBase::TB_Vertical;
|
||||
|
||||
if ((!options.sameThumbSize && (options.thumbSizeTab != options.thumbSize)) || (options.showFileNames || options.filmStripShowFileNames)) {
|
||||
#if PROTECT_VECTORS
|
||||
|
||||
MYWRITERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < fd.size(); i++) {
|
||||
fd[i]->resize (getThumbnailHeight());
|
||||
@ -1070,22 +1021,16 @@ void ThumbBrowserBase::enableTabMode(bool enable)
|
||||
// Scroll to selected position if going into ribbon mode or back
|
||||
// Tab mode is horizontal, file browser is vertical
|
||||
{
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
if (!selected.empty()) {
|
||||
if (enable) {
|
||||
double h = selected[0]->getStartX();
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK_RELEASE(l);
|
||||
#endif
|
||||
hscroll.set_value (min(h, hscroll.get_adjustment()->get_upper()));
|
||||
} else {
|
||||
double v = selected[0]->getStartY();
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK_RELEASE(l);
|
||||
#endif
|
||||
vscroll.set_value (min(v, vscroll.get_adjustment()->get_upper()));
|
||||
}
|
||||
}
|
||||
@ -1114,9 +1059,7 @@ int ThumbBrowserBase::getEffectiveHeight()
|
||||
{
|
||||
int h = hscroll.get_height() + 2; // have 2 pixels rounding error for scroll bars to appear
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, entryRW);
|
||||
#endif
|
||||
|
||||
// Filtered items do not change in size, so take a non-filtered
|
||||
for (size_t i = 0; i < fd.size(); i++)
|
||||
|
@ -321,10 +321,7 @@ void ThumbBrowserEntryBase::getTextSizes (int& infow, int& infoh)
|
||||
|
||||
void ThumbBrowserEntryBase::resize (int h)
|
||||
{
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, lockRW);
|
||||
#endif
|
||||
|
||||
height = h;
|
||||
int old_preh = preh, old_width = width;
|
||||
@ -446,9 +443,7 @@ void ThumbBrowserEntryBase::draw ()
|
||||
return;
|
||||
}
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYREADERLOCK(l, lockRW); // No resizes, position moves etc. inbetween
|
||||
#endif
|
||||
|
||||
int bbWidth, bbHeight;
|
||||
|
||||
@ -486,10 +481,7 @@ void ThumbBrowserEntryBase::draw ()
|
||||
|
||||
void ThumbBrowserEntryBase::setPosition (int x, int y, int w, int h)
|
||||
{
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, lockRW);
|
||||
#endif
|
||||
|
||||
exp_width = w;
|
||||
exp_height = h;
|
||||
@ -503,10 +495,7 @@ void ThumbBrowserEntryBase::setPosition (int x, int y, int w, int h)
|
||||
|
||||
void ThumbBrowserEntryBase::setOffset (int x, int y)
|
||||
{
|
||||
|
||||
#if PROTECT_VECTORS
|
||||
MYWRITERLOCK(l, lockRW);
|
||||
#endif
|
||||
|
||||
ofsX = -x;
|
||||
ofsY = -y;
|
||||
|
Loading…
x
Reference in New Issue
Block a user