mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-10 07:38:06 -05:00
GTK: fix the exit(1) response to startup-time font errors.
For gtkapp-based tools that will have to stop being a program-fatal error, so I've turned it into a function called window_setup_error (which I could in principle reuse for other problems in the long and tortuous progress of new_session_window), and kept the original handling in gtkmain.c's implementation of that function while gtkapp.c does something more sensible with a message box.
This commit is contained in:
parent
ba55b228a3
commit
4b8baed84a
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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");
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user