public void Dispose() { if (disposed) { return; } if (current_nf != null) { try { current_nf.Close(); } catch {} } // Hide the AppIndicator before disposing indicator.Status = Status.Passive; indicator.Dispose(); indicator = null; ServiceManager.PlayerEngine.DisconnectEvent(OnPlayerEvent); elements_service.PrimaryWindowClose = null; Gtk3.Action close_action = interface_action_service.GlobalActions["CloseAction"]; if (close_action != null) { interface_action_service.GlobalActions.Remove(close_action); } if (ui_manager_id >= 0) { interface_action_service.RemoveActionGroup("AppIndicator"); interface_action_service.UIManager.RemoveUi((uint)ui_manager_id); ui_manager_id = -1; } elements_service = null; interface_action_service = null; AddinManager.AddinLoaded -= OnAddinLoaded; disposed = true; }