diff options
author | Nicholas Piper <nicholas@users.sourceforge.net> | 2007-01-14 21:40:16 +0000 |
---|---|---|
committer | Nicholas Piper <nicholas@users.sourceforge.net> | 2007-01-14 21:40:16 +0000 |
commit | 78a7d8e3b4ed5c4eab7d1f6cda419f7a60f612f1 (patch) | |
tree | 86969c6de3b65a8c5c1b66a604a3c9479cab7a08 /bindings | |
parent | 82d93abef813820d98f0d04afc7aac5e00390da3 (diff) | |
download | libgpod-tmz-78a7d8e3b4ed5c4eab7d1f6cda419f7a60f612f1.tar.gz libgpod-tmz-78a7d8e3b4ed5c4eab7d1f6cda419f7a60f612f1.tar.xz libgpod-tmz-78a7d8e3b4ed5c4eab7d1f6cda419f7a60f612f1.zip |
If the Database was garbage collected, then any Tracks would be corrupt. Keep a reference to the Database to avoid this.
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1368 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/python/ipod.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bindings/python/ipod.py b/bindings/python/ipod.py index 4c0d14a..1d02f69 100644 --- a/bindings/python/ipod.py +++ b/bindings/python/ipod.py @@ -101,7 +101,8 @@ class Database: 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 @@ class Database: 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 @@ class Database: """ 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 @@ class Database: 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 @@ class Track: "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 @@ class Track: 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 @@ class Playlist: 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 ? |