Fix a hang when opening a dragged file.

This commit is contained in:
Damiano Galassi committed 2015-05-02 15:35:06 +02:00
1 parent 18af7bce53
commit 8707239891
2 files changed
+10 -10

No files matched your search

+4 -2
View File
@@ -185,13 +185,15 @@
}
- (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL display:(BOOL)displayDocument error:(NSError **)outError {
SBDocument *doc = nil;
__block SBDocument *doc = nil;
if ([[[absoluteURL path] pathExtension] caseInsensitiveCompare: @"mkv"] == NSOrderedSame ||
[[[absoluteURL path] pathExtension] caseInsensitiveCompare: @"mka"] == NSOrderedSame ||
[[[absoluteURL path] pathExtension] caseInsensitiveCompare: @"mks"] == NSOrderedSame ||
[[[absoluteURL path] pathExtension] caseInsensitiveCompare: @"mov"] == NSOrderedSame) {
doc = [self openUntitledDocumentAndDisplay:displayDocument error:outError];
dispatch_sync(dispatch_get_main_queue(), ^{
doc = [self openUntitledDocumentAndDisplay:displayDocument error:outError];
});
[doc performSelectorOnMainThread:@selector(showImportSheet:) withObject:[NSArray arrayWithObject:absoluteURL] waitUntilDone:NO];
return doc;
}
+6 -8
View File
@@ -73,10 +73,11 @@
return nil;
}
- (id)initWithType:(NSString *)typeName error:(NSError **)outError
- (instancetype)initWithType:(NSString *)typeName error:(NSError **)outError
{
if (self = [super initWithType:typeName error:outError])
if (self = [super initWithType:typeName error:outError]) {
self.mp4 = [[[MP42File alloc] initWithDelegate:self] autorelease];
}
return self;
}
@@ -177,8 +178,6 @@
- (BOOL)writeSafelyToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName
forSaveOperation:(NSSaveOperationType)saveOperation error:(NSError **)outError;
{
NSError *inError = nil;
NSMutableDictionary * attributes = [[NSMutableDictionary alloc] init];
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"chaptersPreviewTrack"] boolValue])
[attributes setObject:@YES forKey:MP42GenerateChaptersPreviewTrack];
@@ -201,6 +200,7 @@
IOReturn io_success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep,
kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
BOOL success = NO;
NSError *inError = nil;
switch (saveOperation) {
case NSSaveOperation:
@@ -218,6 +218,8 @@
break;
}
[attributes release];
if (success && _optimize) {
dispatch_async(dispatch_get_main_queue(), ^{
[saveOperationName setStringValue:@"Optimizing…"];
@@ -226,13 +228,10 @@
_optimize = NO;
}
if (io_success == kIOReturnSuccess) {
IOPMAssertionRelease(assertionID);
}
[attributes release];
dispatch_async(dispatch_get_main_queue(), ^{
[self saveDidComplete:inError URL:absoluteURL];
});
@@ -965,4 +964,3 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
}
@end