From 8d5fcf9d223eceafea90af8b94e87e93e92eacd9 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Mon, 13 Mar 2017 17:16:15 +0100 Subject: [PATCH 1/2] Fix a crash that could happens when trying to delete multiple tracks with the metadata row selected. --- Classes/SBDocument.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Classes/SBDocument.m b/Classes/SBDocument.m index be45ca5..e27bb04 100644 --- a/Classes/SBDocument.m +++ b/Classes/SBDocument.m @@ -518,7 +518,8 @@ static NSDictionary *_detailMonospacedAttr; } if (toolbarItem == deleteTrack) { - return self.tracksTable.selectedRow > 0 && NSApp.active; + NSIndexSet *indexes = self.tracksTable.selectedRowIndexes; + return (indexes.count && ![self.tracksTable.selectedRowIndexes containsIndex:0] && NSApp.isActive); } if (toolbarItem == searchMetadata) { @@ -949,7 +950,9 @@ static NSDictionary *_detailMonospacedAttr; } [self.tracksTable.selectedRowIndexes enumerateIndexesUsingBlock:^(NSUInteger index, BOOL *stop) { - [trackIndexes addIndex:[self trackIndexAtAtTableRow:index]]; + if (index > 0) { + [trackIndexes addIndex:[self trackIndexAtAtTableRow:index]]; + } }]; [self.mp4 removeTracksAtIndexes:trackIndexes]; From 1ee2514b05816b19ef48eaae010d3e5afe3bcc65 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Mon, 13 Mar 2017 17:25:41 +0100 Subject: [PATCH 2/2] Disable the offset and export menu item if multiple tracks are selected. --- Classes/SBDocument.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/SBDocument.m b/Classes/SBDocument.m index e27bb04..10a4103 100644 --- a/Classes/SBDocument.m +++ b/Classes/SBDocument.m @@ -488,7 +488,7 @@ static NSDictionary *_detailMonospacedAttr; if (action == @selector(sendToExternalApp:)) return YES; - if (action == @selector(showTrackOffsetSheet:) && self.tracksTable.selectedRow != -1) + if (action == @selector(showTrackOffsetSheet:) && self.tracksTable.selectedRowIndexes.count == 1 && self.tracksTable.selectedRow != -1) return YES; if (action == @selector(addChaptersEvery:)) @@ -503,7 +503,7 @@ static NSDictionary *_detailMonospacedAttr; if (action == @selector(fixAudioFallbacks:)) return YES; - if (action == @selector(export:) && self.tracksTable.selectedRow != -1) + if (action == @selector(export:) && self.tracksTable.selectedRowIndexes.count == 1 && self.tracksTable.selectedRow != -1) if ([[self trackAtAtTableRow:self.tracksTable.selectedRow] respondsToSelector:@selector(exportToURL:error:)] && [self trackAtAtTableRow:self.tracksTable.selectedRow].muxed) return YES;