From 885561442b9411399827a5bec53c4cc884a31862 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Mon, 24 Feb 2014 02:24:45 +0000 Subject: LinGui: fix selection of "feature" title git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6077 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/hb-backend.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 2bab2a7a0..1ce5d7b3d 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -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* -- cgit v1.2.3