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:
@@ -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++)
|
||||
|
Reference in New Issue
Block a user