Commit 76a07e86 authored by David Fuhrmann's avatar David Fuhrmann

macosx: addons manager: process the callback on the main thread

Avoids concurrent access to _addons and _displayedAddons.
parent 77fbebca
...@@ -34,19 +34,21 @@ ...@@ -34,19 +34,21 @@
NSArray *_displayedAddons; NSArray *_displayedAddons;
} }
- (void)addAddon:(addon_entry_t *)data; - (void)addAddon:(NSValue *)o_value;
- (void)discoveryEnded; - (void)discoveryEnded;
- (void)addonChanged:(addon_entry_t *)data; - (void)addonChanged:(NSValue *)o_value;
@end @end
static void addonsEventsCallback( const vlc_event_t *event, void *data ) static void addonsEventsCallback( const vlc_event_t *event, void *data )
{ {
if (event->type == vlc_AddonFound) @autoreleasepool {
[[VLCAddonManager sharedInstance] addAddon:event->u.addon_generic_event.p_entry]; if (event->type == vlc_AddonFound)
else if (event->type == vlc_AddonsDiscoveryEnded) [[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(addAddon:) withObject:[NSValue valueWithPointer:event->u.addon_generic_event.p_entry] waitUntilDone:NO];
[[VLCAddonManager sharedInstance] discoveryEnded]; else if (event->type == vlc_AddonsDiscoveryEnded)
else if (event->type == vlc_AddonChanged) [[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(discoveryEnded) withObject:nil waitUntilDone:NO];
[[VLCAddonManager sharedInstance] addonChanged:event->u.addon_generic_event.p_entry]; else if (event->type == vlc_AddonChanged)
[[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(addonChanged:) withObject:[NSValue valueWithPointer:event->u.addon_generic_event.p_entry] waitUntilDone:NO];
}
} }
@implementation VLCAddonManager @implementation VLCAddonManager
...@@ -228,13 +230,12 @@ static VLCAddonManager *_o_sharedInstance = nil; ...@@ -228,13 +230,12 @@ static VLCAddonManager *_o_sharedInstance = nil;
#pragma mark - data handling #pragma mark - data handling
- (void)addAddon:(addon_entry_t *)p_entry - (void)addAddon:(NSValue *)o_value
{ {
@autoreleasepool { addon_entry_t *p_entry = [o_value pointerValue];
/* no skin support on OS X so far */ /* no skin support on OS X so far */
if (p_entry->e_type != ADDON_SKIN2) if (p_entry->e_type != ADDON_SKIN2)
[_addons addObject:[[[VLCAddon alloc] initWithAddon:p_entry] autorelease]]; [_addons addObject:[[[VLCAddon alloc] initWithAddon:p_entry] autorelease]];
}
} }
- (void)discoveryEnded - (void)discoveryEnded
...@@ -243,7 +244,7 @@ static VLCAddonManager *_o_sharedInstance = nil; ...@@ -243,7 +244,7 @@ static VLCAddonManager *_o_sharedInstance = nil;
[_spinner stopAnimation:nil]; [_spinner stopAnimation:nil];
} }
- (void)addonChanged:(addon_entry_t *)data - (void)addonChanged:(NSValue *)o_value
{ {
[self _refactorDataModel]; [self _refactorDataModel];
} }
...@@ -302,7 +303,9 @@ static VLCAddonManager *_o_sharedInstance = nil; ...@@ -302,7 +303,9 @@ static VLCAddonManager *_o_sharedInstance = nil;
- (void)_findInstalled - (void)_findInstalled
{ {
addons_manager_LoadCatalog(_manager); addons_manager_LoadCatalog(_manager);
[self _refactorDataModel];
// enqueue, to process the addons first
[self performSelectorOnMainThread:@selector(_refactorDataModel) withObject:nil waitUntilDone:NO];
} }
- (void)_installAddonWithID:(NSData *)o_data - (void)_installAddonWithID:(NSData *)o_data
......
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