From b613abc7d6ba8ae7d0e7b0a4a662b1677b4171cf Mon Sep 17 00:00:00 2001 From: ritsuka Date: Wed, 23 Jul 2008 18:51:31 +0000 Subject: [PATCH] MacGui; Fixed a crash when the chapters tableview is selected and a new source is being opened. Some whitespace cleaning too. git-svn-id: svn://localhost/HandBrake/trunk@1574 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/ChapterTitles.m | 34 ++++++++++++++++++++-------------- macosx/Controller.mm | 33 +++++++++++++-------------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/macosx/ChapterTitles.m b/macosx/ChapterTitles.m index cc2d50c2..e957d3ee 100644 --- a/macosx/ChapterTitles.m +++ b/macosx/ChapterTitles.m @@ -65,12 +65,15 @@ { if(aTableColumn != nil && [[aTableColumn identifier] intValue] == 2) { - hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex ); - - if( chapter != NULL ) + if( fTitle ) { - strncpy( chapter->title, [anObject UTF8String], 1023); - chapter->title[1023] = '\0'; + hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex ); + + if( chapter != NULL ) + { + strncpy( chapter->title, [anObject UTF8String], 1023); + chapter->title[1023] = '\0'; + } } } } @@ -87,18 +90,21 @@ } else { - hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex ); - - if( chapter != NULL ) + if( fTitle ) { - cellEntry = [NSString stringWithUTF8String:chapter->title]; - } - else - { - cellEntry = @"__DATA ERROR__"; + hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex ); + + if( chapter != NULL ) + { + cellEntry = [NSString stringWithUTF8String:chapter->title]; + } + else + { + cellEntry = @"__DATA ERROR__"; + } } } - + return cellEntry; } diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 0143763e..abef9b6f 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -1182,9 +1182,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It { [NSApp endSheet: fScanSrcTitlePanel]; [fScanSrcTitlePanel orderOut: self]; - - - + if(sender == fScanSrcTitleOpenButton) { /* We setup the scan status in the main window to indicate a source title scan */ @@ -1200,7 +1198,6 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It } } - /* Here we actually tell hb_scan to perform the source scan, using the path to source and title number*/ - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum { @@ -1208,13 +1205,18 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It BOOL cancelScanDecrypt = 0; NSString *path = scanPath; HBDVDDetector *detector = [HBDVDDetector detectorForPath:path]; + + // Notify ChapterTitles that there's no title + [fChapterTitlesDelegate resetWithTitle:nil]; + [fChapterTable reloadData]; + if( [detector isVideoDVD] ) { // The chosen path was actually on a DVD, so use the raw block // device path instead. path = [detector devicePath]; [self writeToActivityLog: "trying to open a physical dvd at: %s", [scanPath UTF8String]]; - + /* lets check for vlc here to make sure we have a dylib available to use for decrypting */ NSString *vlcPath = @"/Applications/VLC.app"; NSFileManager * fileManager = [NSFileManager defaultManager]; @@ -1243,21 +1245,17 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It cancelScanDecrypt = 0; [self writeToActivityLog: "user overrode vlc warning -trying to open physical dvd without decryption"]; } - + } else { /* VLC was found in /Applications so all is well, we can carry on using vlc's libdvdcss.dylib for decrypting if needed */ [self writeToActivityLog: "VLC app found for decrypting physical dvd"]; } - } - - - + if (cancelScanDecrypt == 0) { - /* we actually pass the scan off to libhb here */ /* If there is no title number passed to scan, we use "0" * which causes the default behavior of a full source scan @@ -1270,6 +1268,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It { [self writeToActivityLog: "scanning specifically for title: %d", scanTitleNum]; } + hb_scan( fHandle, [path UTF8String], scanTitleNum ); [fSrcDVD2Field setStringValue:@"Scanning new source ..."]; } @@ -1281,8 +1280,6 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It [self enableUI: YES]; } } - - } - (IBAction) showNewScan:(id)sender @@ -1291,15 +1288,15 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It hb_title_t * title; int indxpri=0; // Used to search the longuest title (default in combobox) int longuestpri=0; // Used to search the longuest title (default in combobox) - + list = hb_get_titles( fHandle ); - + if( !hb_list_count( list ) ) { /* We display a message if a valid dvd source was not chosen */ [fSrcDVD2Field setStringValue: @"No Valid Source Found"]; SuccessfulScan = NO; - + // Notify ChapterTitles that there's no title [fChapterTitlesDelegate resetWithTitle:nil]; [fChapterTable reloadData]; @@ -2090,10 +2087,6 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It [self doCancelCurrentJob]; // <- this also stops libhb } - - - - - (IBAction) Pause: (id) sender { hb_state_t s; -- 2.11.0