Show number of cleared Litehtml cache images on debug
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 8 Feb 2019 19:09:38 +0000 (20:09 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 12 Feb 2019 18:38:10 +0000 (19:38 +0100)
src/plugins/litehtml_viewer/container_linux.cpp
src/plugins/litehtml_viewer/container_linux.h
src/plugins/litehtml_viewer/lh_widget.cpp

index e4d3c1d..0993f8d 100644 (file)
@@ -834,9 +834,10 @@ void container_linux::clear_images()
        m_images.clear();
 }
 
-void container_linux::clear_images(gint desired_size)
+gint container_linux::clear_images(gint desired_size)
 {
        gint size = 0;
+       gint num = 0;
 
        /* First, tally up size of all the stored GdkPixbufs and
         * deallocate those which make the total size be above
@@ -854,6 +855,7 @@ void container_linux::clear_images(gint desired_size)
                if (size + cursize > desired_size) {
                        g_object_unref(img->second);
                        img->second = NULL;
+                       num++;
                } else {
                        size += cursize;
                }
@@ -865,6 +867,8 @@ void container_linux::clear_images(gint desired_size)
                                return true;
                        return false;
                        });
+
+       return num;
 }
 
 const litehtml::tchar_t* container_linux::get_default_font_name() const
index 8298437..c6cda8e 100644 (file)
@@ -88,7 +88,7 @@ public:
 
        /* Trim down images cache to less than desired_size [bytes],
         * starting from oldest stored. */
-       void                                                            clear_images(gint desired_size);
+       gint                                                            clear_images(gint desired_size);
 
 protected:
        virtual void                                            draw_ellipse(cairo_t* cr, int x, int y, int width, int height, const litehtml::web_color& color, int line_width);
index 3fcb359..61abf61 100644 (file)
@@ -217,7 +217,10 @@ statusbar_pop:
 
 void lh_widget::open_html(const gchar *contents)
 {
-       clear_images(lh_prefs_get()->image_cache_size * 1024 * 1000);
+       gint num = clear_images(lh_prefs_get()->image_cache_size * 1024 * 1000);
+
+       debug_print("LH: cleared %d images from image cache\n", num);
+
        lh_widget_statusbar_push("Loading HTML part ...");
        m_html = litehtml::document::createFromString(contents, this, &m_context);
        m_rendered_width = 0;