[vlc-commits] macosx: addons manager: process the callback on the main thread
David Fuhrmann
git at videolan.org
Mon May 19 11:41:09 CEST 2014
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Mon May 19 11:38:02 2014 +0200| [76a07e86ea5b16e3be567e19b58012de79ae64e0] | committer: David Fuhrmann
macosx: addons manager: process the callback on the main thread
Avoids concurrent access to _addons and _displayedAddons.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=76a07e86ea5b16e3be567e19b58012de79ae64e0
---
modules/gui/macosx/AddonManager.m | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/modules/gui/macosx/AddonManager.m b/modules/gui/macosx/AddonManager.m
index 29e7fa9..1d2c666 100644
--- a/modules/gui/macosx/AddonManager.m
+++ b/modules/gui/macosx/AddonManager.m
@@ -34,19 +34,21 @@
NSArray *_displayedAddons;
}
-- (void)addAddon:(addon_entry_t *)data;
+- (void)addAddon:(NSValue *)o_value;
- (void)discoveryEnded;
-- (void)addonChanged:(addon_entry_t *)data;
+- (void)addonChanged:(NSValue *)o_value;
@end
static void addonsEventsCallback( const vlc_event_t *event, void *data )
{
- if (event->type == vlc_AddonFound)
- [[VLCAddonManager sharedInstance] addAddon:event->u.addon_generic_event.p_entry];
- else if (event->type == vlc_AddonsDiscoveryEnded)
- [[VLCAddonManager sharedInstance] discoveryEnded];
- else if (event->type == vlc_AddonChanged)
- [[VLCAddonManager sharedInstance] addonChanged:event->u.addon_generic_event.p_entry];
+ @autoreleasepool {
+ if (event->type == vlc_AddonFound)
+ [[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(addAddon:) withObject:[NSValue valueWithPointer:event->u.addon_generic_event.p_entry] waitUntilDone:NO];
+ else if (event->type == vlc_AddonsDiscoveryEnded)
+ [[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(discoveryEnded) withObject:nil waitUntilDone:NO];
+ 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
@@ -228,13 +230,12 @@ static VLCAddonManager *_o_sharedInstance = nil;
#pragma mark - data handling
-- (void)addAddon:(addon_entry_t *)p_entry
+- (void)addAddon:(NSValue *)o_value
{
- @autoreleasepool {
- /* no skin support on OS X so far */
- if (p_entry->e_type != ADDON_SKIN2)
- [_addons addObject:[[[VLCAddon alloc] initWithAddon:p_entry] autorelease]];
- }
+ addon_entry_t *p_entry = [o_value pointerValue];
+ /* no skin support on OS X so far */
+ if (p_entry->e_type != ADDON_SKIN2)
+ [_addons addObject:[[[VLCAddon alloc] initWithAddon:p_entry] autorelease]];
}
- (void)discoveryEnded
@@ -243,7 +244,7 @@ static VLCAddonManager *_o_sharedInstance = nil;
[_spinner stopAnimation:nil];
}
-- (void)addonChanged:(addon_entry_t *)data
+- (void)addonChanged:(NSValue *)o_value
{
[self _refactorDataModel];
}
@@ -302,7 +303,9 @@ static VLCAddonManager *_o_sharedInstance = nil;
- (void)_findInstalled
{
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
More information about the vlc-commits
mailing list