banshee r4031 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.Sources
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4031 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.Sources
- Date: Fri, 30 May 2008 01:08:21 +0000 (UTC)
Author: gburt
Date: Fri May 30 01:08:21 2008
New Revision: 4031
URL: http://svn.gnome.org/viewvc/banshee?rev=4031&view=rev
Log:
2008-05-29 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs:
* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Move the
NeedsReload methods into DatabaseSource so they can be used by
PrimarySource and others.
* src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs: Only reload
when track(s) change if needed, otherwise just invalidate the cache.
Should help some with performance/CPU usage when changing songs.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs Fri May 30 01:08:21 2008
@@ -178,55 +178,6 @@
get { return (Parent is DatabaseSource) ? (Parent as DatabaseSource).ShowBrowser : base.ShowBrowser; }
}
- protected bool NeedsReloadWhenFieldsChanged (Hyena.Query.QueryField [] fields)
- {
- if (fields == null) {
- return true;
- }
-
- foreach (QueryField field in fields)
- if (NeedsReloadWhenFieldChanged (field))
- return true;
-
- return false;
- }
-
- private List<QueryField> query_fields;
- private QueryNode last_query;
- protected virtual bool NeedsReloadWhenFieldChanged (Hyena.Query.QueryField field)
- {
- if (field == null)
- return true;
-
- // If it's the artist or album name, then we care, since it affects the browser
- if (field == Banshee.Query.BansheeQuery.ArtistField || field == Banshee.Query.BansheeQuery.AlbumField) {
- return true;
- }
-
- ISortableColumn sort_column = (TrackModel is DatabaseTrackListModel)
- ? (TrackModel as DatabaseTrackListModel).SortColumn : null;
- // If it's the field we're sorting by, then yes, we care
- // FIXME this Contains is very hacky, we should link the ISortableColumn to a field and/or a
- // QueryOrder object
- if (sort_column != null && field.Column.Contains (sort_column.SortKey)) {
- return true;
- }
-
- // Make sure the query isn't dependent on this field
- QueryNode query = (TrackModel is DatabaseTrackListModel)
- ? (TrackModel as DatabaseTrackListModel).Query : null;
- if (query != null) {
- if (query != last_query) {
- query_fields = new List<QueryField> (query.GetFields ());
- }
-
- if (query_fields.Contains (field))
- return true;
- }
-
- return false;
- }
-
protected abstract void Create ();
protected abstract void Update ();
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs Fri May 30 01:08:21 2008
@@ -120,6 +120,56 @@
{
}
+ protected bool NeedsReloadWhenFieldsChanged (Hyena.Query.QueryField [] fields)
+ {
+ if (fields == null) {
+ return true;
+ }
+
+ foreach (QueryField field in fields)
+ if (NeedsReloadWhenFieldChanged (field))
+ return true;
+
+ return false;
+ }
+
+ private List<QueryField> query_fields;
+ private QueryNode last_query;
+ protected virtual bool NeedsReloadWhenFieldChanged (Hyena.Query.QueryField field)
+ {
+ if (field == null)
+ return true;
+
+ // If it's the artist or album name, then we care, since it affects the browser
+ if (field == Banshee.Query.BansheeQuery.ArtistField || field == Banshee.Query.BansheeQuery.AlbumField) {
+ return true;
+ }
+
+ ISortableColumn sort_column = (TrackModel is DatabaseTrackListModel)
+ ? (TrackModel as DatabaseTrackListModel).SortColumn : null;
+ // If it's the field we're sorting by, then yes, we care
+ // FIXME this Contains is very hacky, we should link the ISortableColumn to a field and/or a
+ // QueryOrder object
+ if (sort_column != null && field.Column.Contains (sort_column.SortKey)) {
+ return true;
+ }
+
+ // Make sure the query isn't dependent on this field
+ QueryNode query = (TrackModel is DatabaseTrackListModel)
+ ? (TrackModel as DatabaseTrackListModel).Query : null;
+ if (query != null) {
+ if (query != last_query) {
+ query_fields = new List<QueryField> (query.GetFields ());
+ last_query = query;
+ }
+
+ if (query_fields.Contains (field))
+ return true;
+ }
+
+ return false;
+ }
+
#region Public Properties
public override int Count {
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs Fri May 30 01:08:21 2008
@@ -330,7 +330,13 @@
protected override void OnTracksChanged (params QueryField [] fields)
{
ThreadAssist.SpawnFromMain (delegate {
- Reload ();
+ if (NeedsReloadWhenFieldsChanged (fields)) {
+ Reload ();
+ } else {
+ InvalidateCaches ();
+ }
+
+ System.Threading.Thread.Sleep (150);
TrackEventHandler handler = TracksChanged;
if (handler != null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]