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:
Adam Reichold
2016-01-05 23:59:14 +01:00
parent 5883410354
commit 17d9309f1c
9 changed files with 11 additions and 215 deletions

View File

@@ -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;