diff --git a/rtgui/rtimage.cc b/rtgui/rtimage.cc index cc734456e..6a289ead6 100644 --- a/rtgui/rtimage.cc +++ b/rtgui/rtimage.cc @@ -120,6 +120,10 @@ void RTImage::changeImage (const Glib::ustring& imageName) { clear (); + if (imageName.empty()) { + return; + } + if (pixbuf) { auto iterator = pixbufCache.find (imageName); assert(iterator != pixbufCache.end ()); @@ -169,6 +173,17 @@ void RTImage::init() scaleBack = RTScalable::getScale(); } +void RTImage::cleanup() +{ + for (auto& entry : pixbufCache) { + entry.second.reset(); + } + for (auto& entry : surfaceCache) { + entry.second.clear(); + } + RTScalable::cleanup(); +} + void RTImage::updateImages() { for (auto& entry : pixbufCache) { diff --git a/rtgui/rtimage.h b/rtgui/rtimage.h index 481772ad6..5679f6edc 100644 --- a/rtgui/rtimage.h +++ b/rtgui/rtimage.h @@ -52,6 +52,7 @@ public: static void init(); + static void cleanup(); static void updateImages (); static void setDPInScale (const double newDPI, const int newScale); static void setScale (const int newScale); diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 0d9017fbd..eb9ccf10c 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -463,7 +463,7 @@ RTWindow::~RTWindow() delete fpanel; } - RTScalable::cleanup(); + RTImage::cleanup(); } void RTWindow::on_realize ()