]> granicus.if.org Git - handbrake/commitdiff
LinGui: fix selection of "feature" title
authorjstebbins <jstebbins.hb@gmail.com>
Mon, 24 Feb 2014 02:24:45 +0000 (02:24 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Mon, 24 Feb 2014 02:24:45 +0000 (02:24 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6077 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/hb-backend.c

index 2bab2a7a09445c6e5728511436562ca8fce5e64d..1ce5d7b3d749be128780a4c2c8e9f4f9235333a9 100644 (file)
@@ -2302,16 +2302,26 @@ ghb_longest_title()
 {
     hb_title_set_t * title_set;
     const hb_title_t * title;
-    gint count = 0;
+    gint count = 0, ii, longest = -1;
+    int64_t duration = 0;
 
     g_debug("ghb_longest_title ()\n");
     if (h_scan == NULL) return 0;
     title_set = hb_get_title_set( h_scan );
     count = hb_list_count( title_set->list_title );
-    if (count < 1) return 0;
-    title = hb_list_item(title_set->list_title, 0);
-    (void)title; // Silence "unused variable" warning
-    return title_set->feature;
+    if (count < 1) return -1;
+
+    // Check that the feature title in the title_set exists in the list
+    // of titles.  If not, pick the longest.
+    for (ii = 0; ii < count; ii++)
+    {
+        title = hb_list_item(title_set->list_title, ii);
+        if (title->index == title_set->feature)
+            return title_set->feature;
+        if (title->duration > duration)
+            longest = title->index;
+    }
+    return longest;
 }
 
 const gchar*