Commit eaa1ca1c authored by David Fuhrmann's avatar David Fuhrmann

macosx: remove singletons of ExtensionsDialogProvider and manager

Also deinitalizes both objects. This should fix the refcount
crash on exit.
parent 104ac66f
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
*****************************************************************************/ *****************************************************************************/
@interface ExtensionsDialogProvider : NSObject <NSWindowDelegate> @interface ExtensionsDialogProvider : NSObject <NSWindowDelegate>
+ (ExtensionsDialogProvider *)sharedInstance;
- (void)performEventWithObject: (NSValue *)o_value ofType:(const char*)type; - (void)performEventWithObject: (NSValue *)o_value ofType:(const char*)type;
- (void)triggerClick:(id)sender; - (void)triggerClick:(id)sender;
......
...@@ -253,36 +253,19 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl ...@@ -253,36 +253,19 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl
(void) p_this; (void) p_this;
(void) psz_variable; (void) psz_variable;
(void) old_val; (void) old_val;
(void) param;
ExtensionsDialogProvider *extensionDialogProvider = [ExtensionsDialogProvider sharedInstance]; ExtensionsDialogProvider *provider = (__bridge ExtensionsDialogProvider *)param;
if (!extensionDialogProvider)
return VLC_EGENERIC;
if (!new_val.p_address) if (!new_val.p_address)
return VLC_EGENERIC; return VLC_EGENERIC;
extension_dialog_t *p_dialog = (extension_dialog_t*) new_val.p_address; extension_dialog_t *p_dialog = (extension_dialog_t*) new_val.p_address;
[extensionDialogProvider manageDialog:p_dialog]; [provider manageDialog:p_dialog];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
} }
@interface ExtensionsDialogProvider ()
@end
@implementation ExtensionsDialogProvider @implementation ExtensionsDialogProvider
+ (ExtensionsDialogProvider *)sharedInstance
{
static ExtensionsDialogProvider *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [[ExtensionsDialogProvider alloc] init];
});
return sharedInstance;
}
- (id)init - (id)init
{ {
self = [super init]; self = [super init];
...@@ -297,8 +280,7 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl ...@@ -297,8 +280,7 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl
- (void)dealloc - (void)dealloc
{ {
intf_thread_t *p_intf = VLCIntf; var_DelCallback(VLCIntf, "dialog-extension", extensionDialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-extension", extensionDialogCallback, (__bridge void *)self);
} }
- (void)performEventWithObject:(NSValue *)objectValue ofType:(const char*)type - (void)performEventWithObject:(NSValue *)objectValue ofType:(const char*)type
...@@ -554,8 +536,6 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl ...@@ -554,8 +536,6 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl
- (void)manageDialog:(extension_dialog_t *)p_dialog - (void)manageDialog:(extension_dialog_t *)p_dialog
{ {
assert(p_dialog); assert(p_dialog);
ExtensionsManager *extMgr = [ExtensionsManager sharedInstance];
assert(extMgr != NULL);
NSValue *o_value = [NSValue valueWithPointer:p_dialog]; NSValue *o_value = [NSValue valueWithPointer:p_dialog];
[self performSelectorOnMainThread:@selector(updateExtensionDialog:) [self performSelectorOnMainThread:@selector(updateExtensionDialog:)
......
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
@interface ExtensionsManager : NSObject @interface ExtensionsManager : NSObject
+ (ExtensionsManager *)sharedInstance;
- (void)buildMenu:(NSMenu *)extMenu; - (void)buildMenu:(NSMenu *)extMenu;
- (BOOL)loadExtensions; - (BOOL)loadExtensions;
......
...@@ -48,22 +48,13 @@ ...@@ -48,22 +48,13 @@
@implementation ExtensionsManager @implementation ExtensionsManager
static ExtensionsManager* instance = nil;
+ (ExtensionsManager *)sharedInstance
{
if (!instance)
instance = [[ExtensionsManager alloc] init];
return instance;
}
- (id)init - (id)init
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
p_extensions_manager = NULL; p_extensions_manager = NULL;
_extensionDialogProvider = [ExtensionsDialogProvider sharedInstance]; _extensionDialogProvider = [[ExtensionsDialogProvider alloc] init];
p_extDict = [[NSMutableDictionary alloc] init]; p_extDict = [[NSMutableDictionary alloc] init];
...@@ -189,18 +180,6 @@ static ExtensionsManager* instance = nil; ...@@ -189,18 +180,6 @@ static ExtensionsManager* instance = nil;
return false; return false;
} }
/* Initialize dialog provider */
_extensionDialogProvider = [ExtensionsDialogProvider sharedInstance];
if (!_extensionDialogProvider) {
msg_Err(p_intf, "Unable to create dialogs provider for extensions");
module_unneed(p_extensions_manager, p_extensions_manager->p_module);
vlc_object_release(p_extensions_manager);
p_extensions_manager = NULL;
b_failed = true;
[delegate extensionsUpdated];
return false;
}
_isUnloading = false; _isUnloading = false;
} }
b_failed = false; b_failed = false;
...@@ -213,6 +192,7 @@ static ExtensionsManager* instance = nil; ...@@ -213,6 +192,7 @@ static ExtensionsManager* instance = nil;
if (!p_extensions_manager) if (!p_extensions_manager)
return; return;
_isUnloading = true; _isUnloading = true;
module_unneed(p_extensions_manager, p_extensions_manager->p_module); module_unneed(p_extensions_manager, p_extensions_manager->p_module);
vlc_object_release(p_extensions_manager); vlc_object_release(p_extensions_manager);
p_extensions_manager = NULL; p_extensions_manager = NULL;
...@@ -323,8 +303,9 @@ static ExtensionsManager* instance = nil; ...@@ -323,8 +303,9 @@ static ExtensionsManager* instance = nil;
- (void)dealloc - (void)dealloc
{ {
intf_thread_t *p_intf = VLCIntf; intf_thread_t *p_intf = VLCIntf;
msg_Dbg(p_intf, "Killing extension dialog provider"); msg_Dbg(p_intf, "Deinitializing extensions manager");
_extensionDialogProvider = nil;
if (p_extensions_manager) if (p_extensions_manager)
vlc_object_release(p_extensions_manager); vlc_object_release(p_extensions_manager);
} }
......
...@@ -230,13 +230,12 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -230,13 +230,12 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
* The serial queue ensures that changed inputs are propagated in the same order as they arrive. * The serial queue ensures that changed inputs are propagated in the same order as they arrive.
*/ */
dispatch_async(informInputChangedQueue, ^{ dispatch_async(informInputChangedQueue, ^{
[[ExtensionsManager sharedInstance] inputChanged:p_input_changed]; [[o_main extensionsManager] inputChanged:p_input_changed];
if (p_input_changed) if (p_input_changed)
vlc_object_release(p_input_changed); vlc_object_release(p_input_changed);
}); });
} }
- (void)playbackStatusUpdated - (void)playbackStatusUpdated
{ {
intf_thread_t *p_intf = VLCIntf; intf_thread_t *p_intf = VLCIntf;
......
...@@ -60,8 +60,6 @@ ...@@ -60,8 +60,6 @@
HelpWindowController *_helpWindowController; HelpWindowController *_helpWindowController;
AddonsWindowController *_addonsController; AddonsWindowController *_addonsController;
ExtensionsManager *_extensionManager;
// information for playlist table columns menu // information for playlist table columns menu
NSDictionary *_translationsForPlaylistTableColumns; NSDictionary *_translationsForPlaylistTableColumns;
NSArray *_menuOrderOfPlaylistTableColumns; NSArray *_menuOrderOfPlaylistTableColumns;
...@@ -79,6 +77,7 @@ ...@@ -79,6 +77,7 @@
- (void)dealloc - (void)dealloc
{ {
msg_Dbg(VLCIntf, "Deinitializing main menu");
[[NSNotificationCenter defaultCenter] removeObserver: self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
[self releaseRepresentedObjects:[NSApp mainMenu]]; [self releaseRepresentedObjects:[NSApp mainMenu]];
...@@ -133,7 +132,6 @@ ...@@ -133,7 +132,6 @@
/* Get ExtensionsManager */ /* Get ExtensionsManager */
intf_thread_t *p_intf = VLCIntf; intf_thread_t *p_intf = VLCIntf;
_extensionManager = [ExtensionsManager sharedInstance];
[self initStrings]; [self initStrings];
...@@ -241,12 +239,13 @@ ...@@ -241,12 +239,13 @@
/* setup extensions menu */ /* setup extensions menu */
/* Let the ExtensionsManager itself build the menu */ /* Let the ExtensionsManager itself build the menu */
[_extensionManager buildMenu:_extensionsMenu]; ExtensionsManager *extMgr = [[VLCMain sharedInstance] extensionsManager];
[extMgr buildMenu:_extensionsMenu];
[_extensions setEnabled: ([_extensionsMenu numberOfItems] > 0)]; [_extensions setEnabled: ([_extensionsMenu numberOfItems] > 0)];
// FIXME: Implement preference for autoloading extensions on mac // FIXME: Implement preference for autoloading extensions on mac
if (![_extensionManager isLoaded] && ![_extensionManager cannotLoad]) if (![extMgr isLoaded] && ![extMgr cannotLoad])
[_extensionManager loadExtensions]; [extMgr loadExtensions];
/* setup post-proc menu */ /* setup post-proc menu */
NSUInteger count = (NSUInteger) [_postprocessingMenu numberOfItems]; NSUInteger count = (NSUInteger) [_postprocessingMenu numberOfItems];
......
...@@ -73,6 +73,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -73,6 +73,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCAudioEffects; @class VLCAudioEffects;
@class VLCVideoEffects; @class VLCVideoEffects;
@class VLCConvertAndSave; @class VLCConvertAndSave;
@class ExtensionsManager;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
...@@ -93,6 +94,8 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -93,6 +94,8 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCCoreDialogProvider *)coreDialogProvider; - (VLCCoreDialogProvider *)coreDialogProvider;
- (ResumeDialogController *)resumeDialog; - (ResumeDialogController *)resumeDialog;
- (VLCInputManager *)inputManager; - (VLCInputManager *)inputManager;
- (ExtensionsManager *)extensionsManager;
- (VLCDebugMessageVisualizer *)debugMsgPanel; - (VLCDebugMessageVisualizer *)debugMsgPanel;
- (VLCTrackSynchronization *)trackSyncPanel; - (VLCTrackSynchronization *)trackSyncPanel;
......
...@@ -174,6 +174,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -174,6 +174,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCAudioEffects *_audioEffectsPanel; VLCAudioEffects *_audioEffectsPanel;
VLCVideoEffects *_videoEffectsPanel; VLCVideoEffects *_videoEffectsPanel;
VLCConvertAndSave *_convertAndSaveWindow; VLCConvertAndSave *_convertAndSaveWindow;
ExtensionsManager *_extensionsManager;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */ bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */
} }
...@@ -213,6 +214,9 @@ static VLCMain *sharedInstance = nil; ...@@ -213,6 +214,9 @@ static VLCMain *sharedInstance = nil;
[VLCApplication sharedApplication].delegate = self; [VLCApplication sharedApplication].delegate = self;
_input_manager = [[VLCInputManager alloc] initWithMain:self];
_extensionsManager = [[ExtensionsManager alloc] init];
_mainmenu = [[VLCMainMenu alloc] init]; _mainmenu = [[VLCMainMenu alloc] init];
_voutController = [[VLCVoutWindowController alloc] init]; _voutController = [[VLCVoutWindowController alloc] init];
_playlist = [[VLCPlaylist alloc] init]; _playlist = [[VLCPlaylist alloc] init];
...@@ -221,8 +225,6 @@ static VLCMain *sharedInstance = nil; ...@@ -221,8 +225,6 @@ static VLCMain *sharedInstance = nil;
var_Create(p_intf, "intf-change", VLC_VAR_BOOL); var_Create(p_intf, "intf-change", VLC_VAR_BOOL);
_input_manager = [[VLCInputManager alloc] initWithMain:self];
var_AddCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self); var_AddCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self);
var_AddCallback(p_intf->p_libvlc, "intf-show", ShowController, (__bridge void *)self); var_AddCallback(p_intf->p_libvlc, "intf-show", ShowController, (__bridge void *)self);
...@@ -514,6 +516,11 @@ static VLCMain *sharedInstance = nil; ...@@ -514,6 +516,11 @@ static VLCMain *sharedInstance = nil;
return _input_manager; return _input_manager;
} }
- (ExtensionsManager *)extensionsManager
{
return _extensionsManager;
}
- (VLCDebugMessageVisualizer *)debugMsgPanel - (VLCDebugMessageVisualizer *)debugMsgPanel
{ {
if (!_messagePanelController) if (!_messagePanelController)
......
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