diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index 022d57f97..3ec02ce85 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -239,6 +239,12 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) { entry->resize (getCurrentThumbSize()); // find place in abc order + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + std::vector::iterator i = fd.begin(); while (i!=fd.end() && *entry < *((FileBrowserEntry*)*i)) i++; @@ -246,10 +252,15 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) { fd.insert (i, entry); initEntry (entry); + } redraw (); } FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif for (std::vector::iterator i=fd.begin(); i!=fd.end(); i++) if ((*i)->filename==fname) { @@ -270,6 +281,10 @@ 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); + #endif for (std::vector::iterator i=fd.begin(); i!=fd.end(); i++) if ((*i)->filename==fname) @@ -288,12 +303,19 @@ void FileBrowser::close () { fbih->destroyed = false; fbih->pending = 0; + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + for (int i=0; irenameRequested (mselected); else if (m==selall) { lastClicked = NULL; + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + selected.clear (); for (int i=0; iselected = true; selected.push_back (fd[i]); } + } queue_draw (); notifySelectionListener (); } @@ -569,6 +598,12 @@ void FileBrowser::applyFilter (const BrowserFilter& filter) { // remove items not complying the filter from the selection bool selchanged = false; numFiltered=0; + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + for (int i=0; i0) { for (int i=fd.size()-1; i>=0; i--) @@ -701,6 +742,10 @@ void FileBrowser::openNextImage () { } void FileBrowser::openPrevImage () { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif if (fd.size()>0) { for (int i=0; isetOffset ((int)(hscroll.get_value()), (int)(vscroll.get_value())); @@ -133,6 +137,10 @@ void ThumbBrowserBase::configScrollBars () { } void ThumbBrowserBase::arrangeFiles () { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif int N = fd.size (); // apply filter @@ -249,6 +257,10 @@ void ThumbBrowserBase::Internal::on_realize() } bool ThumbBrowserBase::Internal::on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr& tooltip) { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(parent->entryMutex); + #endif Glib::ustring ttip = ""; for (int i=0; ifd.size(); i++) @@ -307,6 +319,12 @@ bool ThumbBrowserBase::Internal::on_button_press_event (GdkEventButton* event) { void ThumbBrowserBase::buttonPressed (int x, int y, int button, GdkEventType type, int state, int clx, int cly, int clw, int clh) { ThumbBrowserEntryBase* fileDescr = NULL; bool handled = false; + + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + for (int i=0; idrawable) { if (fd[i]->inside (x, y) && fd[i]->insideWindow (clx, cly, clw, clh)) @@ -409,6 +427,11 @@ bool ThumbBrowserBase::Internal::on_expose_event(GdkEventExpose* event) { Glib::RefPtr window = get_window(); + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(parent->entryMutex); + #endif + int w = get_width(); int h = get_height(); @@ -430,6 +453,11 @@ bool ThumbBrowserBase::Internal::on_expose_event(GdkEventExpose* event) { bool ThumbBrowserBase::Internal::on_button_release_event (GdkEventButton* event) { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(parent->entryMutex); + #endif + int w = get_width(); int h = get_height(); @@ -440,6 +468,10 @@ 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); + #endif int w = get_width(); int h = get_height(); @@ -483,8 +515,15 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) { previewHeight = newHeight; if (inTabMode) options.thumbSizeTab = newHeight; else options.thumbSize = newHeight; - for (int i=0; iresize (previewHeight); + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + + for (int i=0; iresize (previewHeight); + } + redraw (); #ifdef _WIN32 gdk_window_process_updates (get_window()->gobj(), true); @@ -494,6 +533,11 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) { int ThumbBrowserBase::getCurrentThumbSize() { return inTabMode ? options.thumbSizeTab : options.thumbSize; } void ThumbBrowserBase::refreshThumbImages () { + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif for (int i=0; irefreshThumbnailImage (); TODO: This might cause crashes on some installations */ } + } redraw (); } void ThumbBrowserBase::refreshQuickThumbImages () { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + for (int i=0; irefreshQuickThumbnailImage (); } @@ -514,8 +564,16 @@ void ThumbBrowserBase::refreshQuickThumbImages () { void ThumbBrowserBase::refreshEditedState (const std::set& efiles) { editedFiles = efiles; + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + for (int i=0; iframed = editedFiles.find (fd[i]->filename)!=editedFiles.end(); + } + queue_draw (); } @@ -530,6 +588,11 @@ void ThumbBrowserBase::enableTabMode(bool enable) { arrangement = inTabMode ? ThumbBrowserBase::TB_Horizontal : ThumbBrowserBase::TB_Vertical; if (options.thumbSizeTab!=options.thumbSize) { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + for (int i=0; iresize (getCurrentThumbSize()); } @@ -568,7 +631,15 @@ void ThumbBrowserBase::setScrollPosition (double h, double v) { // needed for auto-height in single tab int ThumbBrowserBase::getEffectiveHeight() { int h=0; + { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(entryMutex); + #endif + if (fd.size()>0) h=fd[0]->getEffectiveHeight(); + } + return h; } diff --git a/rtgui/thumbbrowserbase.h b/rtgui/thumbbrowserbase.h index 9cd57641c..c44144fc0 100644 --- a/rtgui/thumbbrowserbase.h +++ b/rtgui/thumbbrowserbase.h @@ -75,6 +75,8 @@ class ThumbBrowserBase : public Gtk::VBox { int eventTime; + Glib::Mutex entryMutex; // Locks access to following vectors + std::vector fd; std::vector selected; ThumbBrowserEntryBase* lastClicked; diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 8787f5d7a..ac2e0f586 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -276,8 +276,13 @@ void Thumbnail::decreaseRef () } void Thumbnail::getThumbnailSize (int &w, int &h) { + // TODO: Check for Linux + #ifdef WIN32 + Glib::Mutex::Lock lock(mutex); + #endif + w=0; - if (tpp) w = tpp->getImageWidth (getProcParams(), h); // this might return 0 if image was just building + if (!initial_ && tpp) w = tpp->getImageWidth (getProcParams(), h); // this might return 0 if image was just building if (w==0) w = tw * h / th; }