From 8be54d42fbb709358b36c3423a82bc333e0f3ba6 Mon Sep 17 00:00:00 2001 From: "B. Nordli" Date: Thu, 31 Dec 2015 15:15:40 +0100 Subject: [PATCH] Better fix for NULL campaign_name --- src/gui.c | 16 +++++----------- src/init.c | 6 ++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui.c b/src/gui.c index 0138eed..e00ca2f 100644 --- a/src/gui.c +++ b/src/gui.c @@ -10806,12 +10806,6 @@ static void read_prefs(void) opt.player_name[50] = '\0'; } - /* Check empty campaign name */ - if (!opt.campaign_name) - { - opt.campaign_name = ""; - } - /* Read GUI options */ opt.hide_card = g_key_file_get_integer(pref_file, "gui", "full_reduced", NULL); @@ -11698,12 +11692,12 @@ static void update_sensitivity() int i; campaign *camp; + /* Find campaign */ + camp = find_campaign(next_campaign); + /* Check for campaign */ - if (strcmp(next_campaign, "")) + if (camp) { - /* Find campaign */ - camp = find_campaign(next_campaign); - /* Set expansion button active */ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(expansion_radio[camp->expanded]), TRUE); @@ -12283,7 +12277,7 @@ static void gui_new_parameters(GtkMenuItem *menu_item, gpointer data) gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), options_frame); /* Create campaign label */ - campaign_label = gtk_label_new(strcmp(opt.campaign_name, "") ? opt.campaign_name : "None"); + campaign_label = gtk_label_new((opt.campaign_name && strcmp(opt.campaign_name, "")) ? opt.campaign_name : "None"); /* Remember campaign */ next_campaign = opt.campaign_name; diff --git a/src/init.c b/src/init.c index 3b0ca1b..f26a8d8 100644 --- a/src/init.c +++ b/src/init.c @@ -944,6 +944,12 @@ campaign *find_campaign(char *campaign_name) { int i; + /* Check for no campaign set */ + if (!campaign_name) + { + return NULL; + } + /* Loop over available campaigns */ for (i = 0; i < num_campaign; i++) {