~fidencio/exaile/0.3.2

« back to all changes in this revision

Viewing changes to xlgui/panel/playlists.py

  • Committer: Johannes Sasongko
  • Date: 2011-02-09 14:22:14 UTC
  • Revision ID: sasongko@gmail.com-20110209142214-rr4nk2gll91s12ko
panel/playlists: Fix 2 bugs where playlist objects in the playlist_nodes cache and the tree model are not kept in sync:

* During playlist deletion, the tree model row is deleted, but playlist_nodes still contains that playlist.

* During playlist modification, only playlist_nodes is updated and not the tree model.

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
            Initializes the mixin
218
218
        """
219
219
        gobject.GObject.__init__(self)
220
 
        self.playlist_nodes = {}
 
220
        self.playlist_nodes = {} # {playlist: iter} cache for custom playlists
221
221
        self.track_image = gtk.gdk.pixbuf_new_from_file(
222
222
            xdg.get_data_path('images/track.png'))
223
223
 
234
234
            else:
235
235
                self.playlist_manager.remove_playlist(
236
236
                    selected_playlist.get_name())
237
 
            #remove from UI
 
237
                # Remove from {playlist: iter} cache.
 
238
                del self.playlist_nodes[selected_playlist]
 
239
            # Remove from UI.
238
240
            selection = self.tree.get_selection()
239
241
            (model, iter) = selection.get_selected()
240
242
            self.model.remove(iter)
621
623
        for playlist in playlists:
622
624
            if playlist.get_name() == pl.get_name():
623
625
                node = self.playlist_nodes[playlist]
 
626
                # Replace the playlist object in {playlist: iter} cache.
624
627
                del self.playlist_nodes[playlist]
625
628
                self.playlist_nodes[pl] = node
 
629
                # Replace the playlist object in tree model.
 
630
                self.model[node][2] = pl
 
631
                # Refresh the playlist subnodes.
626
632
                self._load_playlist_nodes(pl)
627
633
 
628
634
    def add_smart_playlist(self):