Commit 27fcabe2 authored by David Fuhrmann's avatar David Fuhrmann

macosx: Update progress dialog on the main thread, make check thread safe

This should fix some crashes as reported by the users.

(cherry picked from commit 984aadb5ca4f9a8bf01dffae42440320a1ea0f13)
Signed-off-by: default avatarDavid Fuhrmann <dfuhrmann@videolan.org>
parent e6d5e1fb
......@@ -76,6 +76,8 @@
}
+ (VLCCoreDialogProvider *)sharedInstance;
@property (atomic,readwrite) BOOL progressCancelled;
-(void)performEventWithObject: (NSValue *)o_value ofType: (const char*)type;
-(void)showFatalDialog: (NSValue *)o_value;
......@@ -88,7 +90,6 @@
-(void)showProgressDialogOnMainThread: (NSValue *)o_value;
-(void)showProgressDialog: (NSValue *)o_value;
-(IBAction)progDialogAction:(id)sender;
-(BOOL)progressCancelled;
-(void)updateProgressPanelWithText: (NSString *)string andNumber: (double)d_number;
-(void)destroyProgressPanel;
......
......@@ -36,6 +36,8 @@
static VLCCoreDialogProvider *_o_sharedInstance = nil;
@synthesize progressCancelled=b_progress_cancelled;
+ (VLCCoreDialogProvider *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
......@@ -153,10 +155,10 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
{
/* we work-around a Cocoa limitation here, since you cannot delay an execution
* on the main thread within a single call */
b_progress_cancelled = NO;
[self setProgressCancelled:NO];
dialog_progress_bar_t *p_dialog = [o_value pointerValue];
if (!p_dialog || b_progress_cancelled)
if (!p_dialog)
return;
[o_prog_win setTitle: toNSStr(p_dialog->title)];
......@@ -177,7 +179,7 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
{
dialog_progress_bar_t *p_dialog = [o_value pointerValue];
if (!p_dialog || b_progress_cancelled)
if (!p_dialog || [self progressCancelled])
return;
[o_prog_bar setDoubleValue: 0];
......@@ -197,19 +199,14 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
-(void)destroyProgressPanel
{
b_progress_cancelled = YES;
[self setProgressCancelled:YES];
[o_prog_bar performSelectorOnMainThread:@selector(stopAnimation:) withObject:self waitUntilDone:YES];
[o_prog_win performSelectorOnMainThread:@selector(close) withObject:nil waitUntilDone:YES];
}
-(IBAction)progDialogAction:(id)sender
{
b_progress_cancelled = YES;
}
-(BOOL)progressCancelled
{
return b_progress_cancelled;
[self setProgressCancelled:YES];
}
-(id)errorPanel
......
......@@ -521,13 +521,10 @@ void updateProgressPanel (void *priv, const char *text, float value)
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSString *o_txt;
if (text != NULL)
o_txt = [NSString stringWithUTF8String:text];
else
o_txt = @"";
[[[VLCMain sharedInstance] coreDialogProvider] updateProgressPanelWithText: o_txt andNumber: (double)(value * 1000.)];
NSString *o_txt = toNSStr(text);
dispatch_async(dispatch_get_main_queue(), ^{
[[[VLCMain sharedInstance] coreDialogProvider] updateProgressPanelWithText: o_txt andNumber: (double)(value * 1000.)];
});
[o_pool release];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment