Close bundle install sheet on error

Previously incase of error the sheet would keep showing effectively locking up the document window.

This is related to issue #85 although the reason why installing bundles fails for some users is still unanswered.
This commit is contained in:
Allan Odgaard
2013-04-23 18:57:25 +07:00
parent cdb75619ca
commit 9083ca8206

View File

@@ -205,15 +205,22 @@ static bool is_installed (oak::uuid_t const& uuid)
{
if(bundleUUID == (*bundle)->uuid())
{
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(checkIfBundleIsInstalled:) userInfo:[grammar objectForKey:@"uuid"] repeats:YES];
[[BundlesManager sharedInstance] installBundle:*bundle completionHandler:nil];
[installingBundleActivityTextField bind:NSValueBinding toObject:[BundlesManager sharedInstance] withKeyPath:@"activityText" options:nil];
[installingBundleProgressIndicator bind:NSValueBinding toObject:[BundlesManager sharedInstance] withKeyPath:@"progress" options:nil];
[installingBundleProgressIndicator bind:NSIsIndeterminateBinding toObject:[BundlesManager sharedInstance] withKeyPath:@"determinateProgress" options:@{ NSValueTransformerNameBindingOption: @"NSNegateBoolean" }];
[installingBundleProgressIndicator startAnimation:self];
OakShowSheetForWindow(installingBundleWindow, aWindow, ^(NSInteger returnCode){
aCompletionHandler(self.fileType);
});
OakShowSheetForWindow(installingBundleWindow, aWindow, ^(NSInteger returnCode){ });
[[BundlesManager sharedInstance] installBundle:*bundle completionHandler:^(BOOL success){
[installingBundleProgressIndicator stopAnimation:self];
[installingBundleProgressIndicator unbind:NSValueBinding];
[installingBundleActivityTextField unbind:NSValueBinding];
[NSApp endSheet:installingBundleWindow];
[installingBundleWindow orderOut:self];
aCompletionHandler(is_installed(uuid) ? self.fileType : @"text.plain");
}];
return;
}
}
@@ -222,21 +229,6 @@ static bool is_installed (oak::uuid_t const& uuid)
});
}
- (void)checkIfBundleIsInstalled:(NSTimer*)aTimer
{
NSString* uuid = [aTimer userInfo];
if(is_installed(to_s(uuid)))
{
[aTimer invalidate];
[installingBundleProgressIndicator stopAnimation:self];
[installingBundleProgressIndicator unbind:NSValueBinding];
[installingBundleActivityTextField unbind:NSValueBinding];
[NSApp endSheet:installingBundleWindow];
[installingBundleWindow orderOut:self];
}
}
- (IBAction)performOpenDocument:(id)sender
{
[self.window orderOut:self];