From 982883bafae3df039a25f137bfb2084ebb67150d Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Sun, 27 Mar 2016 10:17:54 -0700 Subject: [PATCH] LinGui: fix crash when no preset selected and scan new source --- gtk/src/presets.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 167356690..dd1676b1f 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -330,13 +330,13 @@ ghb_preset_to_settings(GhbValue *settings, GhbValue *preset) } const gchar *mode = ghb_dict_get_string(settings, "VideoFramerateMode"); - if (strcmp(mode, "cfr") == 0) + if (mode != NULL && strcmp(mode, "cfr") == 0) { ghb_dict_set_bool(settings, "VideoFramerateCFR", TRUE); ghb_dict_set_bool(settings, "VideoFrameratePFR", FALSE); ghb_dict_set_bool(settings, "VideoFramerateVFR", FALSE); } - else if (strcmp(mode, "pfr") == 0) + else if (mode != NULL && strcmp(mode, "pfr") == 0) { ghb_dict_set_bool(settings, "VideoFramerateCFR", FALSE); ghb_dict_set_bool(settings, "VideoFrameratePFR", TRUE); @@ -388,30 +388,33 @@ ghb_preset_to_settings(GhbValue *settings, GhbValue *preset) char *tok; videoTune = g_strdup(ghb_dict_get_string(settings, "VideoTune")); - tok = strtok_r(videoTune, ",./-+", &saveptr); - ghb_dict_set_bool(settings, "x264FastDecode", FALSE); - ghb_dict_set_bool(settings, "x264ZeroLatency", FALSE); - while (tok != NULL) + if (videoTune != NULL) { - if (!strcasecmp(tok, "fastdecode")) + tok = strtok_r(videoTune, ",./-+", &saveptr); + ghb_dict_set_bool(settings, "x264FastDecode", FALSE); + ghb_dict_set_bool(settings, "x264ZeroLatency", FALSE); + while (tok != NULL) { - ghb_dict_set_bool(settings, "x264FastDecode", TRUE); - } - else if (!strcasecmp(tok, "zerolatency")) - { - ghb_dict_set_bool(settings, "x264ZeroLatency", TRUE); - } - else if (tune == NULL) - { - tune = g_strdup(tok); - } - else - { - ghb_log("Superfluous tunes! %s", tok); + if (!strcasecmp(tok, "fastdecode")) + { + ghb_dict_set_bool(settings, "x264FastDecode", TRUE); + } + else if (!strcasecmp(tok, "zerolatency")) + { + ghb_dict_set_bool(settings, "x264ZeroLatency", TRUE); + } + else if (tune == NULL) + { + tune = g_strdup(tok); + } + else + { + ghb_log("Superfluous tunes! %s", tok); + } + tok = strtok_r(NULL, ",./-+", &saveptr); } - tok = strtok_r(NULL, ",./-+", &saveptr); + g_free(videoTune); } - g_free(videoTune); if (tune != NULL) { ghb_dict_set_string(settings, "VideoTune", tune); -- 2.40.0