]> granicus.if.org Git - handbrake/commitdiff
LinGui: fix crash when no preset selected and scan new source
authorJohn Stebbins <jstebbins.hb@gmail.com>
Sun, 27 Mar 2016 17:17:54 +0000 (10:17 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Sun, 27 Mar 2016 17:17:54 +0000 (10:17 -0700)
gtk/src/presets.c

index 16735669074d8f15c4567533cd37e1f398b0b714..dd1676b1fe553faae18a7feb0868233e699490fa 100644 (file)
@@ -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);