OSDN Git Service

LinGui: Fix a crash with re-scanning prior to encoding. Incorrect title
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 6 Sep 2008 22:43:10 +0000 (22:43 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 6 Sep 2008 22:43:10 +0000 (22:43 +0000)
index was being used.  Must be sure to use title->index for this.

git-svn-id: svn://localhost/HandBrake/trunk@1672 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/callbacks.c
gtk/src/hb-backend.c
gtk/src/hb-backend.h

index 36013fa..ff07928 100644 (file)
@@ -2707,6 +2707,8 @@ queue_add(signal_user_data_t *ud)
 {
        // Add settings to the queue
        GValue *settings;
+       gint titleindex;
+       gint titlenum;
        
        g_debug("queue_add ()");
        if (!validate_settings(ud))
@@ -2719,6 +2721,9 @@ queue_add(signal_user_data_t *ud)
        settings = ghb_value_dup(ud->settings);
        ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING);
        ghb_settings_set_int(settings, "job_unique_id", 0);
+       titleindex = ghb_settings_get_int(settings, "title");
+       titlenum = ghb_get_title_number(titleindex);
+       ghb_settings_set_int(settings, "titlenum", titlenum);
        ghb_array_append(ud->queue, settings);
        add_to_queue_list(ud, settings);
        ghb_save_queue(ud->queue);
@@ -2880,11 +2885,11 @@ static void
 queue_scan(GValue *js)
 {
        gchar *path;
-       gint titleindex;
+       gint titlenum;
 
        path = ghb_settings_get_string( js, "source");
-       titleindex = ghb_settings_get_int(js, "title");
-       ghb_backend_queue_scan(path, titleindex+1);
+       titlenum = ghb_settings_get_int(js, "titlenum");
+       ghb_backend_queue_scan(path, titlenum);
        g_free(path);
 }
 
index eb60ad9..8054320 100644 (file)
@@ -683,6 +683,25 @@ ghb_hb_cleanup(gboolean partial)
        del_tree(dir, !partial);
 }
 
+gint
+ghb_get_title_number(gint titleindex)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+    hb_audio_config_t *audio = NULL;
+       
+    if (h_scan == NULL) return 1;
+       list = hb_get_titles( h_scan );
+       if( !hb_list_count( list ) )
+       {
+               /* No valid title, stop right there */
+               return NULL;
+       }
+    title = hb_list_item( list, titleindex );
+       if (title == NULL) return 1;    // Bad titleindex
+       return title->index;
+}
+
 static hb_audio_config_t*
 get_hb_audio(gint titleindex, gint track)
 {
@@ -1682,10 +1701,10 @@ ghb_backend_scan(const gchar *path, gint titleindex)
 }
 
 void
-ghb_backend_queue_scan(const gchar *path, gint titleindex)
+ghb_backend_queue_scan(const gchar *path, gint titlenum)
 {
        g_debug("ghb_backend_queue_scan()");
-    hb_scan( h_queue, path, titleindex );
+       hb_scan( h_queue, path, titlenum );
        hb_status.queue_state |= GHB_STATE_SCANNING;
 }
 
index 19ba420..2d04a00 100644 (file)
@@ -120,6 +120,7 @@ GdkPixbuf* ghb_get_preview_image(
        gint titleindex, gint index, GValue *settings, gboolean borders);
 gint ghb_calculate_target_bitrate(GValue *settings, gint titleindex);
 gchar* ghb_dvd_volname(const gchar *device);
+gint ghb_get_title_number(gint titleindex);
 
 gint ghb_guess_bitrate(GValue *settings);
 gboolean ghb_validate_container(signal_user_data_t *ud);