From 744583f32bdf9fce96c64d56ed61b58a5da5d843 Mon Sep 17 00:00:00 2001 From: natureh 510 Date: Mon, 11 Mar 2013 23:15:41 +0100 Subject: [PATCH] Solving issue 1769: "Single Editor mode: unnecessary thumbnail refresh when switching from tab to tab" --- rtgui/rtwindow.cc | 12 +++++++----- rtgui/thumbbrowserentrybase.cc | 7 ++++++- rtgui/thumbimageupdater.cc | 10 +++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 2ac2874fa..000b57c86 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -288,18 +288,20 @@ bool RTWindow::on_window_state_event(GdkEventWindowState* event) { } void RTWindow::on_mainNB_switch_page(GtkNotebookPage* page, guint page_num) { - if (page_num > 1) { + if (page_num > 1) { if (isSingleTabMode()) MoveFileBrowserToEditor(); - EditorPanel *ep = static_cast(mainNB->get_nth_page(page_num)); - ep->setAspect(); - } else { + EditorPanel *ep = static_cast(mainNB->get_nth_page(page_num)); + ep->setAspect(); + } else { // in single tab mode with command line filename epanel does not exist yet if (isSingleTabMode() && epanel) { // Save profile on leaving the editor panel epanel->saveProfile(); - MoveFileBrowserToMain(); + // Moving the FileBrowser only if the user has switched to the FileBrowser tab + if (page_num==0) + MoveFileBrowserToMain(); } } } diff --git a/rtgui/thumbbrowserentrybase.cc b/rtgui/thumbbrowserentrybase.cc index bbbd79a60..f38e854da 100644 --- a/rtgui/thumbbrowserentrybase.cc +++ b/rtgui/thumbbrowserentrybase.cc @@ -57,7 +57,12 @@ void ThumbBrowserEntryBase::updateBackBuffer () { Gtk::Widget* w = parent->getDrawingArea (); - backBuffer = Gdk::Pixmap::create (w->get_window(), exp_width, exp_height); + Glib::RefPtr win = w->get_window(); + if (!win) + // Nothing to draw on, so we return + return; + + backBuffer = Gdk::Pixmap::create (win, exp_width, exp_height); // If thumbnail is hidden by a filter drawing to it will crash int backbuffer_w=0, backbuffer_h=0; diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 3352a6e70..90f2c3621 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -26,7 +26,7 @@ #include #endif -#define DEBUG(format,args...) +#define DEBUG(format,args...) //#define DEBUG(format,args...) printf("ThumbImageUpdate::%s: " format "\n", __FUNCTION__, ## args) class @@ -138,7 +138,7 @@ public: // remove so not run again jobs_.erase(i); - DEBUG("%d job(s) remaining",jobs_.size()); + DEBUG("%d job(s) remaining", int(jobs_.size()) ); ++active_; } @@ -215,7 +215,7 @@ ThumbImageUpdater::add(ThumbBrowserEntryBase* tbe, bool* priority, bool upgrade, i->listener_ == l && i->upgrade_ == upgrade ) { - DEBUG("updating job %s",tbe->getFileName().c_str()); + DEBUG("updating job %s",tbe->shortname.c_str()); // we have one, update queue entry, will be picked up by thread when processed /*i->pparams_ = params; i->height_ = height; */ @@ -225,10 +225,10 @@ ThumbImageUpdater::add(ThumbBrowserEntryBase* tbe, bool* priority, bool upgrade, } // create a new job and append to queue - DEBUG("queing job %s",t->getFileName().c_str()); + DEBUG("queing job %s",tbe->shortname.c_str()); impl_->jobs_.push_back(Impl::Job(tbe,priority,upgrade,l)); - DEBUG("adding run request %s",t->getFileName().c_str()); + DEBUG("adding run request %s",tbe->shortname.c_str()); impl_->threadPool_->push(sigc::mem_fun(*impl_, &ThumbImageUpdater::Impl::processNextJob)); }