diff --git a/libgphoto2/gphoto2-widget.c b/libgphoto2/gphoto2-widget.c index 2471a34c3..8d9778011 100644 --- a/libgphoto2/gphoto2-widget.c +++ b/libgphoto2/gphoto2-widget.c @@ -760,10 +760,16 @@ gp_widget_get_range (CameraWidget *range, float *min, float *max, int gp_widget_add_choice (CameraWidget *widget, const char *choice) { + int i; + C_PARAMS (widget && choice); C_PARAMS ((widget->type == GP_WIDGET_RADIO) || (widget->type == GP_WIDGET_MENU)); + for (i=0;ichoice_count;i++) + if (!strcmp(widget->choice[i],choice)) + return GP_OK; + C_MEM (widget->choice = realloc (widget->choice, sizeof(char*)*(widget->choice_count+1))); C_MEM (widget->choice[widget->choice_count] = strdup(choice)); widget->choice_count += 1;