]> granicus.if.org Git - handbrake/commitdiff
MacGui: fix an issue where a "none" track could be added to hb_job_t.
authorritsuka <damiog@gmail.com>
Sat, 31 Jan 2015 17:07:18 +0000 (17:07 +0000)
committerritsuka <damiog@gmail.com>
Sat, 31 Jan 2015 17:07:18 +0000 (17:07 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6841 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBJob+HBJobConversion.m
macosx/HBSubtitles.m

index 314c320b2315971d6283d9fe8b46f4a0a5acaefa..65e25fe8bb8c4834beb55c72c0970216dc2c004a 100644 (file)
 
     // Map the settings in the dictionaries for the SubtitleList array to match title->list_subtitle
     BOOL one_burned = NO;
-    int i = 0;
-
     for (NSDictionary *subtitleDict in self.subtitles.tracks)
     {
+        int subtitle = [subtitleDict[keySubTrackIndex] intValue];
+        BOOL force = [subtitleDict[keySubTrackForced] boolValue];
+        BOOL burned = [subtitleDict[keySubTrackBurned] boolValue];
+        BOOL def = [subtitleDict[keySubTrackDefault] boolValue];
+
         // Skip the "None" track.
-        if (i == self.subtitles.tracks.count - 1)
+        if (subtitle == -2)
         {
             continue;
         }
 
-        int subtitle = [subtitleDict[keySubTrackIndex] intValue];
-        int force = [subtitleDict[keySubTrackForced] intValue];
-        int burned = [subtitleDict[keySubTrackBurned] intValue];
-        int def = [subtitleDict[keySubTrackDefault] intValue];
-
-        // if i is 0, then we are in the first item of the subtitles which we need to
-        // check for the "Foreign Audio Search" which would be keySubTrackIndex of -1
-
-        // if we are on the first track and using "Foreign Audio Search"
-        if (i == 0 && subtitle == -1)
+        // we need to check for the "Foreign Audio Search" which would be keySubTrackIndex of -1
+        if (subtitle == -1)
         {
             job->indepth_scan = 1;
 
 
                 sub_config.offset = [subtitleDict[keySubTrackSrtOffset] intValue];
 
-                // we need to srncpy file name and codeset
+                // we need to strncpy file name and codeset
                 strncpy(sub_config.src_filename, [subtitleDict[keySubTrackSrtFilePath] UTF8String], 255);
                 sub_config.src_filename[255] = 0;
                 strncpy(sub_config.src_codeset, [subtitleDict[keySubTrackSrtCharCode] UTF8String], 39);
                     // Only allow one subtitle to be burned into the video
                     if (one_burned)
                         continue;
-                    one_burned = TRUE;
+                    one_burned = YES;
                     sub_config.dest = RENDERSUB;
                 }
 
                     // Only allow one subtitle to be burned into the video
                     if (one_burned)
                         continue;
-                    one_burned = TRUE;
+                    one_burned = YES;
                     sub_config.dest = RENDERSUB;
                 }
 
                 hb_subtitle_add(job, &sub_config, subtitle);
             }
         }
-        i++;
     }
 
     if (one_burned)
index 594a406dcecf458120ff7b972db92fe894c80c38..82eceb963d6bbe7c1af31eabf20336efb7eceac3 100644 (file)
@@ -157,7 +157,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex";
 - (NSMutableDictionary *)createSubtitleTrack
 {
     NSMutableDictionary *newSubtitleTrack = [[NSMutableDictionary alloc] init];
-    newSubtitleTrack[keySubTrackIndex] = @0;
+    newSubtitleTrack[keySubTrackIndex] = @(-2);
     newSubtitleTrack[keySubTrackSelectionIndex] = @0;
     newSubtitleTrack[keySubTrackName] = @"None";
     newSubtitleTrack[keySubTrackForced] = @0;