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