[banshee/gio-hardware] [Mtp] Avoid null iterator
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gio-hardware] [Mtp] Avoid null iterator
- Date: Tue, 27 Jul 2010 10:31:40 +0000 (UTC)
commit cf484bff58a2003f0eaf68f2edb224bb0bfbc2b1
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Jul 27 02:45:27 2010 -0700
[Mtp] Avoid null iterator
.../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
index f2172a8..c4d08d0 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -180,15 +180,18 @@ namespace Banshee.Dap.Mtp
SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND ExternalID = ?");
lock (mtp_device) {
- foreach (MTP.Playlist playlist in mtp_device.GetPlaylists ()) {
- PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
- pl_src.Save ();
- // TODO a transaction would make sense here (when the threading issue is fixed)
- foreach (int id in playlist.TrackIds) {
- ServiceManager.DbConnection.Execute (insert_cmd, pl_src.DbId, this.DbId, id);
+ var playlists = mtp_device.GetPlaylists ();
+ if (playlists != null) {
+ foreach (MTP.Playlist playlist in playlists) {
+ PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
+ pl_src.Save ();
+ // TODO a transaction would make sense here (when the threading issue is fixed)
+ foreach (int id in playlist.TrackIds) {
+ ServiceManager.DbConnection.Execute (insert_cmd, pl_src.DbId, this.DbId, id);
+ }
+ pl_src.UpdateCounts ();
+ AddChildSource (pl_src);
}
- pl_src.UpdateCounts ();
- AddChildSource (pl_src);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]