Update of /cvsroot/gtkpod/libgpod/bindings/python
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv13680/bindings/python

Modified Files:
        ipod.py 
Log Message:
If the Database was garbage collected, then any Tracks would be corrupt. Keep a 
reference to the Database to avoid this.

Index: ipod.py
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/bindings/python/ipod.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ipod.py     14 Jan 2007 20:29:38 -0000      1.10
+++ ipod.py     14 Jan 2007 21:40:16 -0000      1.11
@@ -101,7 +101,8 @@
         else:
             if index < 0:
                 index += len(self)
-            return Track(proxied_track=gpod.sw_get_track(self._itdb.tracks, 
index))
+            return Track(proxied_track=gpod.sw_get_track(self._itdb.tracks, 
index),
+                         ownerdb=self)
 
     def __len__(self):
         return gpod.sw_get_list_len(self._itdb.tracks)
@@ -116,6 +117,7 @@
         track.copy_to_ipod()
         gpod.itdb_playlist_add_track(gpod.itdb_playlist_mpl(self._itdb),
                                      track._track, -1)
+        track.__database = self # so the db doesn't get gc'd
 
     def __del__(self):
         gpod.itdb_free(self._itdb)
@@ -129,6 +131,7 @@
         """
 
         gpod.itdb_track_add(self._itdb, track._track, pos)
+        track.__database = self # so the db doesn't get gc'd
 
     def remove(self, item, harddisk=False, ipod=True):
         """Remove a playlist or track from a database.
@@ -211,6 +214,7 @@
             self.Podcasts.add(track)
         else:
             self.Master.add(track)
+        track.__database = self # so the db doesn't get gc'd            
         return track
 
     def copy_delayed_files(self,callback=False):
@@ -280,7 +284,7 @@
                            "usertype")
 
     def __init__(self, filename=None, from_file=None,
-                 proxied_track=None, podcast=False):
+                 proxied_track=None, podcast=False, ownerdb=None):
         """Create a Track object.
 
         If from_file or filename is set, the file specified will be
@@ -332,6 +336,7 @@
             self.set_podcast(podcast)
         elif proxied_track:
             self._track = proxied_track
+            self.__database = ownerdb # so the db doesn't get gc'd
         else:
             self._track = gpod.itdb_track_new()
             self.set_podcast(podcast)
@@ -641,7 +646,8 @@
         else:
             if index < 0:
                 index += len(self)
-            return Track(proxied_track=gpod.sw_get_track(self._pl.members, 
index))
+            return Track(proxied_track=gpod.sw_get_track(self._pl.members, 
index),
+                         ownerdb=self)
 
     def __len__(self):
         #return self._pl.num # Always 0 ?


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to