@@ -92,11 +92,6 @@ enum {
9292 FIND_LAST_SIGNAL
9393};
9494
95- #if ENABLE_EPUB
96- static GtkWidget * webview ;
97- static GtkWidget * offscreenwindow ;
98- #endif
99-
10095static guint job_signals [LAST_SIGNAL ] = { 0 };
10196static guint job_fonts_signals [FONTS_LAST_SIGNAL ] = { 0 };
10297static guint job_find_signals [FIND_LAST_SIGNAL ] = { 0 };
@@ -877,8 +872,12 @@ snapshot_callback(WebKitWebView *webview,
877872
878873 ev_document_doc_mutex_unlock ();
879874 ev_job_succeeded (EV_JOB (job_thumb ));
875+
876+ gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (webview )));
880877}
881878
879+ #endif /* ENABLE_EPUB */
880+
882881static void
883882web_thumbnail_get_screenshot_cb (WebKitWebView * webview ,
884883 WebKitLoadEvent event ,
@@ -906,9 +905,10 @@ webview_load_failed_cb (WebKitWebView *webview,
906905 GError * e = (GError * ) error ;
907906 g_warning ("Error loading data from %s: %s" , failing_uri , e -> message );
908907 ev_job_failed_from_error (EV_JOB (job_thumb ), e );
908+
909+ gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (webview )));
909910 return TRUE;
910911}
911- #endif /* ENABLE_EPUB */
912912
913913static gboolean
914914ev_job_thumbnail_run (EvJob * job )
@@ -939,24 +939,23 @@ ev_job_thumbnail_run (EvJob *job)
939939
940940#if ENABLE_EPUB
941941 if (job -> document -> iswebdocument == TRUE) {
942- if (!webview ) {
943- webview = webkit_web_view_new ();
944- g_signal_connect (WEBKIT_WEB_VIEW (webview ),"load-changed" ,
945- G_CALLBACK (web_thumbnail_get_screenshot_cb ),
946- g_object_ref (job_thumb ));
947- g_signal_connect (WEBKIT_WEB_VIEW (webview ),"load-failed" ,
948- G_CALLBACK (webview_load_failed_cb ),
949- g_object_ref (job_thumb ));
950- }
951-
952- if (!offscreenwindow ) {
953- offscreenwindow = gtk_offscreen_window_new ();
954- gtk_container_add (GTK_CONTAINER (offscreenwindow ),GTK_WIDGET (webview ));
955- gtk_window_set_default_size (GTK_WINDOW (offscreenwindow ),800 ,1080 );
956- gtk_widget_show_all (offscreenwindow );
957- }
958-
959- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (webview ),(gchar * )rc -> page -> backend_page );
942+ GtkWidget * webview ;
943+ GtkWidget * offscreenwindow ;
944+
945+ webview = webkit_web_view_new ();
946+ offscreenwindow = gtk_offscreen_window_new ();
947+
948+ gtk_container_add (GTK_CONTAINER (offscreenwindow ), GTK_WIDGET (webview ));
949+ gtk_window_set_default_size (GTK_WINDOW (offscreenwindow ), 800 , 1080 );
950+ gtk_widget_show_all (offscreenwindow );
951+
952+ g_signal_connect (WEBKIT_WEB_VIEW (webview ), "load-changed" ,
953+ G_CALLBACK (web_thumbnail_get_screenshot_cb ),
954+ g_object_ref (job_thumb ));
955+ g_signal_connect (WEBKIT_WEB_VIEW (webview ), "load-failed" ,
956+ G_CALLBACK (webview_load_failed_cb ),
957+ g_object_ref (job_thumb ));
958+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (webview ), (gchar * ) rc -> page -> backend_page );
960959 }
961960 else
962961#endif /* ENABLE_EPUB */
0 commit comments