diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index 51f042443..661902b9e 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -1158,7 +1158,13 @@ MULTIHANDLER(fullscreen) MULTIHANDLER(viewsource) { - nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level)); + nserror ret; + + ret = nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level)); + if (ret != NSERROR_OK) { + warn_user(messages_get_errorcode(ret), 0); + } + return TRUE; } diff --git a/gtk/viewsource.c b/gtk/viewsource.c index abc9f9483..62e595900 100644 --- a/gtk/viewsource.c +++ b/gtk/viewsource.c @@ -28,7 +28,7 @@ #include "gtk/viewdata.h" #include "gtk/viewsource.h" -void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw) +nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw) { nserror ret; struct hlcache_handle *hlcontent; @@ -41,11 +41,11 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw) hlcontent = browser_window_get_content(bw); if (hlcontent == NULL) { - return; + return NSERROR_BAD_PARAMETER; } if (content_get_type(hlcontent) != CONTENT_HTML) { - return; + return NSERROR_BAD_CONTENT; } source_data = content_get_source_data(hlcontent, &source_size); @@ -54,11 +54,15 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw) if (ret != NSERROR_OK) { filename = strdup(messages_get("SaveSource")); if (filename == NULL) { - return; + return NSERROR_NOMEM; } } title = malloc(strlen(nsurl_access(browser_window_get_url(bw))) + SLEN("Source of - NetSurf") + 1); + if (title == NULL) { + free(filename); + return NSERROR_NOMEM; + } sprintf(title, "Source of %s - NetSurf", nsurl_access(browser_window_get_url(bw))); ret = utf8_from_enc(source_data, @@ -72,4 +76,6 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw) free(filename); free(title); + + return ret; } diff --git a/gtk/viewsource.h b/gtk/viewsource.h index fe85b30b5..bba878874 100644 --- a/gtk/viewsource.h +++ b/gtk/viewsource.h @@ -19,7 +19,7 @@ #ifndef _NETSURF_GTK_VIEWSOURCE_H_ #define _NETSURF_GTK_VIEWSOURCE_H_ -void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw); +nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw); #endif