diff --git a/unix/gtkapp.c b/unix/gtkapp.c index d7add6d1..6a48da35 100644 --- a/unix/gtkapp.c +++ b/unix/gtkapp.c @@ -109,6 +109,7 @@ https://wiki.gnome.org/Projects/GTK%2B/OSX/Bundling has some links. #define MAY_REFER_TO_GTK_IN_HEADERS #include "putty.h" +#include "gtkmisc.h" char *x_get_default(const char *key) { return NULL; } @@ -226,6 +227,19 @@ void new_app_win(GtkApplication *app) launch_new_session(); } +static void window_setup_error_callback(void *vctx, int result) +{ + g_application_release(G_APPLICATION(app)); +} + +void window_setup_error(const char *errmsg) +{ + create_message_box(NULL, "Error creating session window", errmsg, + string_width("Some sort of fiddly error message that " + "might be technical"), + TRUE, &buttons_ok, window_setup_error_callback, NULL); +} + static void activate(GApplication *app, gpointer user_data) { diff --git a/unix/gtkmain.c b/unix/gtkmain.c index a3cdb270..9860cd79 100644 --- a/unix/gtkmain.c +++ b/unix/gtkmain.c @@ -309,6 +309,12 @@ void cmdline_error(const char *p, ...) exit(1); } +void window_setup_error(const char *errmsg) +{ + fprintf(stderr, "%s: %s\n", appname, errmsg); + exit(1); +} + int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch, Conf *conf) { diff --git a/unix/gtkwin.c b/unix/gtkwin.c index f0c3c3fb..a427b20a 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -4639,17 +4639,21 @@ void new_session_window(Conf *conf, const char *geometry_string) inst->area = gtk_drawing_area_new(); gtk_widget_set_name(GTK_WIDGET(inst->area), "drawing-area"); + { + char *errmsg = setup_fonts_ucs(inst); + if (errmsg) { + window_setup_error(errmsg); + sfree(errmsg); + gtk_widget_destroy(inst->area); + sfree(inst); + return; + } + } + #if GTK_CHECK_VERSION(2,0,0) inst->imc = gtk_im_multicontext_new(); #endif - { - char *errmsg = setup_fonts_ucs(inst); - if (errmsg) { - fprintf(stderr, "%s: %s\n", appname, errmsg); - exit(1); - } - } inst->window = make_gtk_toplevel_window(inst); gtk_widget_set_name(GTK_WIDGET(inst->window), "top-level"); { diff --git a/unix/unix.h b/unix/unix.h index 8dcfa24f..2516bf3e 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -135,6 +135,7 @@ void launch_duplicate_session(Conf *conf); void launch_new_session(void); void launch_saved_session(const char *str); void session_window_closed(void); +void window_setup_error(const char *errmsg); #ifdef MAY_REFER_TO_GTK_IN_HEADERS GtkWidget *make_gtk_toplevel_window(void *frontend); #endif