From 14cd0fec836cf228b2279da0c53ae43a32d7b1fb Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 7 Jan 2019 05:54:37 +0100 Subject: badwolf.c: Handle web-process-terminated --- badwolf.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/badwolf.c b/badwolf.c index 86c994b..13c0940 100644 --- a/badwolf.c +++ b/badwolf.c @@ -11,6 +11,28 @@ static gboolean WebViewCb_close(WebKitWebView *_webView, GtkWidget *window) return TRUE; } +static gboolean WebViewCb_web_process_terminated(WebKitWebView *web_view, WebKitWebProcessTerminationReason reason, gpointer user_data) +{ + char *str_reason; + + switch(reason) { + case WEBKIT_WEB_PROCESS_CRASHED: + str_reason = "the web process crashed."; + break; + ;; + case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: + str_reason = "the web process exceeded the memory limit."; + break; + ;; + default: + str_reason = "the web process terminated for an unknown reason."; + ;; + } + + fprintf(stderr, "BadWolf [signal: web-process-terminated]: %s", str_reason); + return TRUE; +} + static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GtkWidget *location) { const gchar *location_uri; @@ -45,6 +67,7 @@ int main(int argc, char *argv[]) g_signal_connect(main_window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(webView, "close", G_CALLBACK(WebViewCb_close), main_window); + g_signal_connect(webView, "web-process-terminated", G_CALLBACK(WebViewCb_web_process_terminated), NULL); g_signal_connect(webView, "notify::uri", G_CALLBACK(WebViewCb_notify__uri), location); WebKitSettings *settings = webkit_web_view_get_settings(webView); -- cgit v1.3.1-23-gd82d