Author: abock
Date: 2007-03-29 13:37:31 -0500 (Thu, 29 Mar 2007)
New Revision: 75166

Modified:
   trunk/ipod-sharp/ChangeLog
   trunk/ipod-sharp/src/Track.cs
   trunk/ipod-sharp/src/TrackDatabase.cs
Log:
2007-03-29  Aaron Bockover  <[EMAIL PROTECTED]>

    * src/TrackDatabase.cs:
    * src/Track.cs: Add null checks for the artwork DB as on some devices we
    may not be able to read the format info, and we shouldn't crash if that's
    the case



Modified: trunk/ipod-sharp/ChangeLog
===================================================================
--- trunk/ipod-sharp/ChangeLog  2007-03-29 18:28:29 UTC (rev 75165)
+++ trunk/ipod-sharp/ChangeLog  2007-03-29 18:37:31 UTC (rev 75166)
@@ -1,3 +1,10 @@
+2007-03-29  Aaron Bockover  <[EMAIL PROTECTED]>
+
+       * src/TrackDatabase.cs:
+       * src/Track.cs: Add null checks for the artwork DB as on some devices we
+       may not be able to read the format info, and we shouldn't crash if 
that's
+       the case
+
 2007-03-23  Aaron Bockover  <[EMAIL PROTECTED]>
 
        * src/Firmware/DmgFirmwareExtract.cs: Updated so my old work isn't 
lost, 

Modified: trunk/ipod-sharp/src/Track.cs
===================================================================
--- trunk/ipod-sharp/src/Track.cs       2007-03-29 18:28:29 UTC (rev 75165)
+++ trunk/ipod-sharp/src/Track.cs       2007-03-29 18:37:31 UTC (rev 75166)
@@ -269,7 +269,7 @@
         }
 
         private void FindCoverPhoto () {
-            if (coverPhoto == null) {
+            if (coverPhoto == null && db.ArtworkDatabase != null) {
                 coverPhoto = db.ArtworkDatabase.LookupPhotoByTrackId 
(record.DatabaseId);
             }
         }
@@ -293,10 +293,17 @@
                 if (!createNew)
                     return null;
                 
-                coverPhoto = db.ArtworkDatabase.CreatePhoto ();
-                coverPhoto.Record.TrackId = record.DatabaseId;
+                
+                if (db.ArtworkDatabase != null) {
+                    coverPhoto = db.ArtworkDatabase.CreatePhoto ();
+                    coverPhoto.Record.TrackId = record.DatabaseId;
+                }
             }
 
+            if (coverPhoto == null) {
+                return null;
+            }
+
             Thumbnail thumbnail = coverPhoto.LookupThumbnail (format);
             if (thumbnail == null && createNew) {
                 thumbnail = coverPhoto.CreateThumbnail ();
@@ -319,7 +326,7 @@
         public void RemoveCoverArt () {
             FindCoverPhoto ();
 
-            if (coverPhoto != null) {
+            if (coverPhoto != null && db.ArtworkDatabase != null) {
                 db.ArtworkDatabase.RemovePhoto (coverPhoto);
             }
         }

Modified: trunk/ipod-sharp/src/TrackDatabase.cs
===================================================================
--- trunk/ipod-sharp/src/TrackDatabase.cs       2007-03-29 18:28:29 UTC (rev 
75165)
+++ trunk/ipod-sharp/src/TrackDatabase.cs       2007-03-29 18:37:31 UTC (rev 
75166)
@@ -1320,7 +1320,8 @@
                 PlaylistList.Save (db, childWriter);
                 break;
             default:
-                throw new DatabaseReadException ("Can't handle DataSet record 
index: " + Index);
+                //throw new DatabaseReadException ("Can't handle DataSet 
record index: " + Index);
+                               break;
             }
 
             childWriter.Flush ();
@@ -1617,7 +1618,11 @@
 
             Reload (createFresh);
 
-            artdb = new PhotoDatabase (device, false, createFresh);
+            try {
+                artdb = new PhotoDatabase (device, false, createFresh);
+            } catch {
+                artdb = null;
+            }
         }
         
         
@@ -1811,7 +1816,7 @@
 
                 uniqueName += ext;
             } while(File.Exists(basePath + uniqueName));
-                               
+
             return uniqueName.Replace("/", ":");
         }
 
@@ -1904,7 +1909,9 @@
                 }
 
                 // Save artwork database
-                artdb.Save ();
+                if (artdb != null) {
+                    artdb.Save ();
+                }
 
                 // Save the shuffle tracks db (will only create if device is 
shuffle);
                 try {
@@ -2020,11 +2027,13 @@
                 dbrec[DataSetIndex.Playlist].Library.RemoveTrack 
(track.Record.Id);
 
                 // remove from cover art db
-                Photo artPhoto = artdb.LookupPhotoByTrackId 
(track.Record.DatabaseId);
-                if (artPhoto != null) {
-                    artdb.RemovePhoto (artPhoto);
+                if (artdb != null) {
+                    Photo artPhoto = artdb.LookupPhotoByTrackId 
(track.Record.DatabaseId);
+                    if (artPhoto != null) {
+                        artdb.RemovePhoto (artPhoto);
+                    }
                 }
-                    
+
                 // remove from the "normal" playlists
                 foreach (Playlist list in playlists) {
                     list.RemoveTrack (track);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to