Merged master into gtk3, manually copied rtgui/threadutils.h over from master

This commit is contained in:
Beep6581
2016-01-31 00:00:28 +01:00
12 changed files with 541 additions and 810 deletions

View File

@@ -59,9 +59,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()));
@@ -204,9 +202,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 ());
@@ -261,9 +257,7 @@ void ThumbBrowserBase::selectPrev (int distance, bool enlarge)
}
}
#if PROTECT_VECTORS
MYWRITERLOCK_RELEASE(l);
#endif
selectionChanged ();
}
@@ -276,9 +270,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 ());
@@ -333,9 +325,7 @@ void ThumbBrowserBase::selectNext (int distance, bool enlarge)
}
}
#if PROTECT_VECTORS
MYWRITERLOCK_RELEASE(l);
#endif
selectionChanged ();
}
@@ -348,9 +338,7 @@ void ThumbBrowserBase::selectFirst (bool enlarge)
getScrollPosition (h, v);
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif
if (!fd.empty ()) {
// find first unfiltered entry
@@ -401,9 +389,7 @@ void ThumbBrowserBase::selectFirst (bool enlarge)
}
}
#if PROTECT_VECTORS
MYWRITERLOCK_RELEASE(l);
#endif
selectionChanged ();
}
@@ -416,9 +402,7 @@ void ThumbBrowserBase::selectLast (bool enlarge)
getScrollPosition (h, v);
{
#if PROTECT_VECTORS
MYWRITERLOCK(l, entryRW);
#endif
if (!fd.empty ()) {
// find last unfiltered entry
@@ -471,9 +455,7 @@ void ThumbBrowserBase::selectLast (bool enlarge)
}
}
#if PROTECT_VECTORS
MYWRITERLOCK_RELEASE(l);
#endif
selectionChanged ();
}
@@ -544,10 +526,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
@@ -608,9 +587,7 @@ void ThumbBrowserBase::arrangeFiles ()
currx += maxw;
}
#if PROTECT_VECTORS
MYREADERLOCK_RELEASE(l);
#endif
// This will require a Writer access
resizeThumbnailArea (currx, numOfRows * rowHeight);
} else {
@@ -687,9 +664,7 @@ void ThumbBrowserBase::arrangeFiles ()
}
}
#if PROTECT_VECTORS
MYREADERLOCK_RELEASE(l);
#endif
// This will require a Writer access
resizeThumbnailArea (colsWidth, curry);
}
@@ -747,9 +722,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)) {
@@ -826,7 +799,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) {
@@ -844,7 +817,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]);
@@ -857,18 +830,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);
@@ -895,9 +868,7 @@ bool ThumbBrowserBase::Internal::on_draw(const ::Cairo::RefPtr< Cairo::Context>
context->set_font_description (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)) {
@@ -918,21 +889,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;
@@ -944,15 +909,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);
}
@@ -1004,9 +964,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);
@@ -1024,9 +982,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);
@@ -1038,9 +994,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 ();
@@ -1052,9 +1006,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();
@@ -1077,9 +1029,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());
@@ -1091,22 +1042,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()));
}
}
@@ -1135,9 +1080,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++)