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>
Sat, 4 May 2019 14:49:35 +0000 (16:49 +0200)
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 29985648cb5b246f2444f46b230267187e767c95..fd74a3b11d5e91e2eb2c2172604b3fe74ca9dda3 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;
 }