[banshee/gtk3] Port to the dispose pattern in all Glib.Object subclasses
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gtk3] Port to the dispose pattern in all Glib.Object subclasses
- Date: Sat, 16 Jul 2011 21:39:21 +0000 (UTC)
commit 9f0d4774d5856497aa797c7f98146552f433a9fc
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sat Jul 16 23:31:21 2011 +0200
Port to the dispose pattern in all Glib.Object subclasses
Glib.Object now implements the dispose pattern, so all subclasses that
were previously implementing Dispose () must now implement
Dispose (bool disposing).
.../Banshee.Collection.Gui/AlbumListView.cs | 9 ++++++---
.../Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs | 8 +++++---
.../Banshee.Gui.Widgets/CoverArtDisplay.cs | 4 ++--
.../Banshee.Gui.Widgets/TrackInfoDisplay.cs | 20 +++++++++++---------
.../Banshee.Gui/BaseClientWindow.cs | 11 ++++++-----
.../Banshee.Sources.Gui/SourceModel.cs | 10 ++++++----
src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs | 14 ++++++++------
.../Banshee.Audiobook/BookView.cs | 12 +++++++-----
.../Banshee.Lastfm/Banshee.Lastfm/LastfmActions.cs | 14 ++++++++------
.../LastfmStreamingActions.cs | 18 ++++++++++--------
.../Banshee.NotificationArea/TrackInfoPopup.cs | 10 ++++++----
.../X11NotificationAreaBox.cs | 17 +++++++++--------
.../Banshee.NowPlaying/NowPlayingContents.cs | 20 +++++++++++---------
.../Banshee.NowPlaying/NowPlayingInterface.cs | 12 +++++++-----
.../Banshee.PlayQueue/PlayQueueActions.cs | 10 ++++++----
.../Banshee.Podcasting.Gui/PodcastActions.cs | 12 +++++++-----
16 files changed, 115 insertions(+), 86 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
index 26dfaab..0142f70 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
@@ -83,10 +83,13 @@ namespace Banshee.Collection.Gui
protected AlbumListView (IntPtr ptr) : base () {}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
- Banshee.Metadata.MetadataService.Instance.ArtworkUpdated -= OnArtworkUpdated;
+ if (disposing) {
+ ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+ Banshee.Metadata.MetadataService.Instance.ArtworkUpdated -= OnArtworkUpdated;
+ }
+ base.Dispose (disposing);
}
private void ToggleAlbumGrid ()
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs
index 78b5011..3995756 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs
@@ -57,10 +57,12 @@ namespace Banshee.Gui.Widgets
{
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- base.Dispose ();
- HidePopup ();
+ if (disposing) {
+ HidePopup ();
+ }
+ base.Dispose (disposing);
}
protected override int ArtworkSizeRequest {
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs
index a557f09..1f9581f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/CoverArtDisplay.cs
@@ -53,14 +53,14 @@ namespace Banshee.Gui.Widgets
{
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
var disposable = idle_album as IDisposable;
if (disposable != null) {
disposable.Dispose ();
}
- base.Dispose ();
+ base.Dispose (disposing);
}
protected override int ArtworkSizeRequest {
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
index bfca4e1..a777c04 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
@@ -156,20 +156,22 @@ namespace Banshee.Gui.Widgets
);
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- if (idle_timeout_id > 0) {
- GLib.Source.Remove (idle_timeout_id);
- }
+ if (disposing) {
+ if (idle_timeout_id > 0) {
+ GLib.Source.Remove (idle_timeout_id);
+ }
- Connected = false;
+ Connected = false;
- stage.Iteration -= OnStageIteration;
- stage = null;
+ stage.Iteration -= OnStageIteration;
+ stage = null;
- InvalidateCache ();
+ InvalidateCache ();
+ }
- base.Dispose ();
+ base.Dispose (disposing);
}
protected override void OnRealized ()
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
index 1428a7a..d6f89e6 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
@@ -86,15 +86,15 @@ namespace Banshee.Gui
}
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- base.Dispose ();
-
try {
Gtk.AccelMap.Save (accel_map_file);
} catch (Exception e) {
Hyena.Log.Exception ("Failed to save custom AccelMap", e);
}
+
+ base.Dispose (disposing);
}
protected void InitialShowPresent ()
@@ -209,7 +209,8 @@ namespace Banshee.Gui
OnTitleChanged ();
}
- protected void OnToolbarExposeEvent (object o, ExposeEventArgs args)
+ // FIXME: confirm that this is not needed anymore
+ /*protected void OnToolbarExposeEvent (object o, ExposeEventArgs args)
{
Toolbar toolbar = (Toolbar)o;
@@ -223,6 +224,6 @@ namespace Banshee.Gui
foreach (Widget child in toolbar.Children) {
toolbar.PropagateExpose (child, args.Event);
}
- }
+ }*/
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs
index f2ce25e..6569317 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs
@@ -84,11 +84,13 @@ namespace Banshee.Sources.Gui
ServiceManager.SourceManager.SourceRemoved += OnSourceRemoved;
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- ServiceManager.SourceManager.SourceAdded -= OnSourceAdded;
- ServiceManager.SourceManager.SourceRemoved -= OnSourceRemoved;
- base.Dispose ();
+ if (disposing) {
+ ServiceManager.SourceManager.SourceAdded -= OnSourceAdded;
+ ServiceManager.SourceManager.SourceRemoved -= OnSourceRemoved;
+ }
+ base.Dispose (disposing);
}
private void OnSourceAdded (SourceAddedArgs args)
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
index cc64f8a..81c5349 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
@@ -69,14 +69,16 @@ namespace Banshee.Dap.Gui
dap.Properties.PropertyChanged += OnPropertyChanged;
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- foreach (var opt in library_opts.Values) {
- opt.Dispose ();
+ if (disposing) {
+ foreach (var opt in library_opts.Values) {
+ opt.Dispose ();
+ }
+ library_opts.Clear ();
}
- library_opts.Clear ();
-
- base.Dispose ();
+
+ base.Dispose (disposing);
}
private void BuildWidgets ()
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
index efe3eb3..aef39d1 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
@@ -129,14 +129,16 @@ namespace Banshee.Audiobook
);
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- if (cover != null) {
- cover.Dispose ();
- cover = null;
+ if (disposing) {
+ if (cover != null) {
+ cover.Dispose ();
+ cover = null;
+ }
}
- base.Dispose ();
+ base.Dispose (disposing);
}
#region ISourceContents
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmActions.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmActions.cs
index ac27a98..cf7838b 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmActions.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm/LastfmActions.cs
@@ -128,13 +128,15 @@ namespace Banshee.Lastfm
UpdateActions ();
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- Actions.UIManager.RemoveUi (actions_id);
- Actions.RemoveActionGroup (this);
- lastfm.Connection.StateChanged -= HandleConnectionStateChanged;
- ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
- base.Dispose ();
+ if (disposing) {
+ Actions.UIManager.RemoveUi (actions_id);
+ Actions.RemoveActionGroup (this);
+ lastfm.Connection.StateChanged -= HandleConnectionStateChanged;
+ ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+ }
+ base.Dispose (disposing);
}
#region Action Handlers
diff --git a/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming/LastfmStreamingActions.cs b/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming/LastfmStreamingActions.cs
index 60120a6..d62aafc 100644
--- a/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming/LastfmStreamingActions.cs
+++ b/src/Extensions/Banshee.LastfmStreaming/Banshee.LastfmStreaming/LastfmStreamingActions.cs
@@ -118,15 +118,17 @@ namespace Banshee.LastfmStreaming.Radio
UpdateActions ();
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- Actions.UIManager.RemoveUi (actions_id);
- Actions.RemoveActionGroup (this);
- lastfm.Connection.StateChanged -= HandleConnectionStateChanged;
- Actions.SourceActions ["SourcePropertiesAction"].Activated -= OnSourceProperties;
- ServiceManager.PlaybackController.SourceChanged -= OnPlaybackSourceChanged;
- ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
- base.Dispose ();
+ if (disposing) {
+ Actions.UIManager.RemoveUi (actions_id);
+ Actions.RemoveActionGroup (this);
+ lastfm.Connection.StateChanged -= HandleConnectionStateChanged;
+ Actions.SourceActions ["SourcePropertiesAction"].Activated -= OnSourceProperties;
+ ServiceManager.PlaybackController.SourceChanged -= OnPlaybackSourceChanged;
+ ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+ }
+ base.Dispose (disposing);
}
#region Action Handlers
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
index 8c5e81e..cd19f88 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
@@ -67,11 +67,13 @@ namespace Banshee.NotificationArea
box.ShowAll ();
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- seek_slider.Disconnect ();
- header.Dispose ();
- base.Dispose ();
+ if (disposing) {
+ seek_slider.Disconnect ();
+ header.Dispose ();
+ }
+ base.Dispose (disposing);
}
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs
index fabbbac..6767c75 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/X11NotificationAreaBox.cs
@@ -88,15 +88,16 @@ namespace Banshee.NotificationArea
event_box.ShowAll ();
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- HidePopup ();
-
- event_box.ButtonPressEvent -= OnButtonPressEvent;
- event_box.EnterNotifyEvent -= OnEnterNotifyEvent;
- event_box.LeaveNotifyEvent -= OnLeaveNotifyEvent;
- event_box.ScrollEvent -= OnMouseScroll;
+ if (disposing) {
+ HidePopup ();
+ event_box.ButtonPressEvent -= OnButtonPressEvent;
+ event_box.EnterNotifyEvent -= OnEnterNotifyEvent;
+ event_box.LeaveNotifyEvent -= OnLeaveNotifyEvent;
+ event_box.ScrollEvent -= OnMouseScroll;
+ }
Destroy ();
}
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs
index 04721af..ff716e6 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingContents.cs
@@ -91,18 +91,20 @@ namespace Banshee.NowPlaying
CheckIdle ();
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- IVideoDisplay ivideo_display = video_display as IVideoDisplay;
- if (ivideo_display != null) {
- ivideo_display.IdleStateChanged -= OnVideoDisplayIdleStateChanged;
- }
+ if (disposing) {
+ IVideoDisplay ivideo_display = video_display as IVideoDisplay;
+ if (ivideo_display != null) {
+ ivideo_display.IdleStateChanged -= OnVideoDisplayIdleStateChanged;
+ }
- if (video_display != null) {
- video_display = null;
+ if (video_display != null) {
+ video_display = null;
+ }
}
- base.Dispose ();
+ base.Dispose (disposing);
}
protected override void OnShown ()
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
index b6ce7cb..5aa028d 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
@@ -88,12 +88,14 @@ namespace Banshee.NowPlaying
screensaver = new ScreensaverManager ();
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- base.Dispose ();
- fullscreen_adapter.SuggestUnfullscreen -= OnAdapterSuggestUnfullscreen;
- fullscreen_adapter.Dispose ();
- screensaver.Dispose ();
+ if (disposing) {
+ fullscreen_adapter.SuggestUnfullscreen -= OnAdapterSuggestUnfullscreen;
+ fullscreen_adapter.Dispose ();
+ screensaver.Dispose ();
+ }
+ base.Dispose (disposing);
}
private void MoveVideoExternal (bool hidden)
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs
index 1a8caa9..94c54ca 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs
@@ -117,11 +117,13 @@ namespace Banshee.PlayQueue
Register ();
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- playqueue.Updated -= OnUpdated;
- ServiceManager.SourceManager.ActiveSourceChanged -= OnSourceUpdated;
- base.Dispose ();
+ if (disposing) {
+ playqueue.Updated -= OnUpdated;
+ ServiceManager.SourceManager.ActiveSourceChanged -= OnSourceUpdated;
+ }
+ base.Dispose (disposing);
}
#region Action Handlers
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
index 619a4a0..f77f749 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
@@ -176,12 +176,14 @@ namespace Banshee.Podcasting.Gui
OnSelectionChanged (null, null);
}
- public override void Dispose ()
+ protected override void Dispose (bool disposing)
{
- ServiceManager.SourceManager.ActiveSourceChanged -= HandleActiveSourceChanged;
- Actions.UIManager.RemoveUi (actions_id);
- Actions.RemoveActionGroup (this);
- base.Dispose ();
+ if (disposing) {
+ ServiceManager.SourceManager.ActiveSourceChanged -= HandleActiveSourceChanged;
+ Actions.UIManager.RemoveUi (actions_id);
+ Actions.RemoveActionGroup (this);
+ }
+ base.Dispose (disposing);
}
#region State Event Handlers
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]