Skip to content

Commit

Permalink
Better fix for NULL campaign_name
Browse files Browse the repository at this point in the history
  • Loading branch information
bnordli committed Dec 31, 2015
1 parent d4054dd commit 8be54d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down

0 comments on commit 8be54d4

Please sign in to comment.