Make preview resistent to nothing being selected
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 20 Apr 2016 21:56:31 +0000 (23:56 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 20 Apr 2016 21:56:31 +0000 (23:56 +0200)
The name of the selected file could be a null pointer, and ScaleOnePiece
does not like that for a pieceImageDirectory.

gtk/xoptions.c

index a12a050..f64a2d5 100644 (file)
@@ -1110,9 +1110,11 @@ BrowseCallback (GtkFileChooser *chooser, gpointer data)
     char *name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
     Option *opt = currentOption + (int)(intptr_t) data;
     int n = (int) (intptr_t) opt->choice;
-    Preview(n, name);
-    messedUp = TRUE;
-    if(name) g_free(name);
+    if(name) {
+       Preview(n, name);
+       messedUp = TRUE;
+       g_free(name);
+    }
     return FALSE;
 }