OSDN Git Service

dvdnav: fix crash when poorly masterd disc has no menus
[handbrake-jp/handbrake-jp-git.git] / macosx / ChapterTitles.m
index cc2d50c..893c2dc 100644 (file)
 - (void)tableView:(NSTableView *)aTableView
         setObjectValue:(id)anObject
         forTableColumn:(NSTableColumn *)aTableColumn
-        row:(int)rowIndex
+        row:(NSInteger)rowIndex
 {
     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';
+            }
         }
     }
 }
 
 - (id)tableView:(NSTableView *)aTableView
       objectValueForTableColumn:(NSTableColumn *)aTableColumn
-      row:(int)rowIndex
+      row:(NSInteger)rowIndex
 {
-    NSString *cellEntry;
+    NSString *cellEntry =  @"__DATA ERROR__";
 
     if([[aTableColumn identifier] intValue] == 1)
     {
     }
     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];
+            }
         }
     }
-    
+
     return cellEntry;
 }
 
@@ -109,11 +111,11 @@ a timer to avoid interfering with the chain of events that handles the edit. */
     NSTableView *chapterTable = [notification object];
     NSInteger column = [chapterTable editedColumn];
     NSInteger row = [chapterTable editedRow];
-    int textMovement;
+    NSInteger textMovement;
 
     // Edit the cell in the next row, same column
     row++;
-    textMovement = [[[notification userInfo] objectForKey:@"NSTextMovement"] intValue];
+    textMovement = [[[notification userInfo] objectForKey:@"NSTextMovement"] integerValue];
     if( textMovement == NSReturnTextMovement && row < [chapterTable numberOfRows] )
     {
         NSArray *info = [NSArray arrayWithObjects:chapterTable,