@@ -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 };
@@ -827,6 +822,7 @@ ev_job_thumbnail_dispose (GObject *object)
827822}
828823
829824#if ENABLE_EPUB
825+
830826static void
831827snapshot_callback (WebKitWebView * webview ,
832828 GAsyncResult * results ,
@@ -859,8 +855,12 @@ snapshot_callback(WebKitWebView *webview,
859855
860856 ev_document_doc_mutex_unlock ();
861857 ev_job_succeeded (EV_JOB (job_thumb ));
858+
859+ gtk_widget_destroy (gtk_widget_get_toplevel (webview ));
862860}
863861
862+ #endif /* ENABLE_EPUB */
863+
864864static void
865865web_thumbnail_get_screenshot_cb (WebKitWebView * webview ,
866866 WebKitLoadEvent event ,
@@ -888,9 +888,11 @@ webview_load_failed_cb (WebKitWebView *webview,
888888 GError * e = (GError * ) error ;
889889 g_warning ("Error loading data from %s: %s" , failing_uri , e -> message );
890890 ev_job_failed_from_error (EV_JOB (job_thumb ), e );
891+
892+ gtk_widget_destroy (gtk_widget_get_toplevel (webview ));
893+
891894 return TRUE;
892895}
893- #endif /* ENABLE_EPUB */
894896
895897static gboolean
896898ev_job_thumbnail_run (EvJob * job )
@@ -921,24 +923,24 @@ ev_job_thumbnail_run (EvJob *job)
921923
922924#if ENABLE_EPUB
923925 if (job -> document -> iswebdocument == TRUE) {
924- if (! webview ) {
925- webview = webkit_web_view_new () ;
926- g_signal_connect ( WEBKIT_WEB_VIEW ( webview ), "load-changed" ,
927- G_CALLBACK ( web_thumbnail_get_screenshot_cb ),
928- g_object_ref ( job_thumb ) );
929- g_signal_connect ( WEBKIT_WEB_VIEW ( webview ), "load-failed" ,
930- G_CALLBACK ( webview_load_failed_cb ),
931- g_object_ref ( job_thumb ));
932- }
933-
934- if (! offscreenwindow ) {
935- offscreenwindow = gtk_offscreen_window_new ();
936- gtk_container_add ( GTK_CONTAINER ( offscreenwindow ), GTK_WIDGET ( webview ));
937- gtk_window_set_default_size ( GTK_WINDOW ( offscreenwindow ), 800 , 1080 );
938- gtk_widget_show_all ( offscreenwindow );
939- }
940-
941- webkit_web_view_load_uri ( WEBKIT_WEB_VIEW ( webview ), (gchar * )rc -> page -> backend_page );
926+
927+ GtkWidget * webview ;
928+ GtkWidget * offscreenwindow ;
929+
930+ webview = webkit_web_view_new ( );
931+ offscreenwindow = gtk_offscreen_window_new ();
932+
933+ gtk_container_add ( GTK_CONTAINER ( offscreenwindow ), GTK_WIDGET ( webview ));
934+ gtk_window_set_default_size ( GTK_WINDOW ( offscreenwindow ), 800 , 1080 );
935+ gtk_widget_show_all ( offscreenwindow );
936+
937+ g_signal_connect ( WEBKIT_WEB_VIEW ( webview ), "load-changed" ,
938+ G_CALLBACK ( web_thumbnail_get_screenshot_cb ),
939+ g_object_ref ( job_thumb ) );
940+ g_signal_connect ( WEBKIT_WEB_VIEW ( webview ), "load-failed" ,
941+ G_CALLBACK ( webview_load_failed_cb ),
942+ g_object_ref ( job_thumb ));
943+ webkit_web_view_load_uri ( webview , (gchar * ) rc -> page -> backend_page );
942944 }
943945 else
944946#endif /* ENABLE_EPUB */
0 commit comments