Properly free previous document from memory in litehtml's clear()
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 29 Jan 2019 20:47:53 +0000 (21:47 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 12 Feb 2019 18:38:10 +0000 (19:38 +0100)
We also call paint_white() earlier in redraw().
This results in properly clearing the previously
rendered html content when opening a different
HTML part.

src/plugins/litehtml_viewer/lh_widget.cpp

index 2998564..fd74a3b 100644 (file)
@@ -240,10 +240,10 @@ void lh_widget::redraw()
        GdkWindow *gdkwin;
        cairo_t *cr;
 
-       if (m_html == NULL) {
-               g_warning("lh_widget::redraw: No document!");
+       paint_white();
+
+       if (m_html == NULL)
                return;
-       }
 
        /* Get width of the viewport. */
        gdkwin = gtk_viewport_get_view_window(GTK_VIEWPORT(m_viewport));
@@ -269,8 +269,6 @@ void lh_widget::redraw()
                                m_html->width(), m_html->height());
        }
 
-       paint_white();
-
        /* Paint the rendered HTML. */
        gdkwin = gtk_widget_get_window(m_drawing_area);
        if (gdkwin == NULL) {
@@ -303,6 +301,7 @@ void lh_widget::paint_white()
 }
 void lh_widget::clear()
 {
+       m_html = nullptr;
        paint_white();
        m_rendered_width = 0;
 }