lzoubek / xbmc-plugin-mpdc

XBMC plugin for remote control of multiple MPD servers
GNU General Public License v3.0
20 stars 13 forks source link

SOLVED:Restart crash on Raspbmc (XBMC on Raspberry Pi) #10 #13

Closed slevit closed 10 years ago

slevit commented 11 years ago

I patched script.mpdc/resources/lib/gui.py that fixes xbmc from crashing when artists & files are clicked. Navigating the add-on now works flawlessly. The only problem is I don't know how to go about getting the mod to lzoubek for distribution. Please advise.

jdmar3 commented 11 years ago

What did you patch exactly? Can you post the changes in a comment? To get the changes to lzoubek you need to do a pull request in the frodo branch for the file that you have changed.

slevit commented 11 years ago

The problem was that the Artists and Files controls were getting reset before needed properties were retrieved. Here are the 2 modified functions (copy/paste in your text editor and search on "srl_2013-06-24_resets":

def _update_artist_browser(self,artist_item=None,client=None,back=False):       
    select_index=0
    index = self.getControl(ARTIST_BROWSER).getSelectedPosition()
    if client == None:
        client = self.client
    if artist_item==None:
        self.getControl(ARTIST_BROWSER).reset()
        artists = self.cache.getArtists()
        if [] == artists:
            artists = self.client.list('artist')
            artists.sort()
            self.cache.putArtists(artists)
        listitem = xbmcgui.ListItem(label='..')
        listitem.setIconImage('DefaultFolderBack.png')
        listitem.setProperty('type','')
        self.getControl(ARTIST_BROWSER).addItem(listitem)           
        for item in artists:
            if not item=='':
                listitem = xbmcgui.ListItem(label=item)
                listitem.setProperty('artist',item)
                listitem.setProperty('type','artist')
                listitem.setIconImage('DefaultMusicArtists.png')
                self.getControl(ARTIST_BROWSER).addItem(listitem)
        if back:
                if not self.ab_indexes == []:
                    select_index = self.ab_indexes.pop()
        self.getControl(ARTIST_BROWSER).selectItem(select_index)
    else:
        typ = artist_item.getProperty('type')
        if typ =='file':
            return
        if typ == '':
            return self._update_artist_browser(back=True)
        else:
            if index == 0 or back:
                if not self.ab_indexes == []:
                    select_index = self.ab_indexes.pop()
            else:
                self.ab_indexes.append(index)
            # *srl_2013-06-24_resets*
                        srl_artist = artist_item.getProperty('artist')
                        srl_artist_album = artist_item.getProperty('album')
            # *srl_2013-06-24_resets* end
            self.getControl(ARTIST_BROWSER).reset()
            if typ == 'artist':                 
                # *srl_2013-06-24_resets* listitem = xbmcgui.ListItem(label='.. %s' % artist_item.getProperty('artist'))
                                    listitem = xbmcgui.ListItem(label='.. %s' % srl_artist)
                # *srl_2013-06-24_resets* end
                listitem.setIconImage('DefaultFolderBack.png')
                listitem.setProperty('type','')
                self.getControl(ARTIST_BROWSER).addItem(listitem)
                # *srl_2013-06-24_resets* albums = self.client.list('album','artist',artist_item.getProperty('artist'))
                                    albums = self.client.list('album','artist',srl_artist)
                # *srl_2013-06-24_resets* end
                sorted_albums = {}
                spaces=''
                for item in albums:
                    # *srl_2013-06-24_resets* date = self.client.list('date','album',item,'artist',artist_item.getProperty('artist'))
                                            date = self.client.list('date','album',item,'artist',srl_artist)
                    # *srl_2013-06-24_resets* end
                    date = date[0]
                    if date =='':
                        date = spaces
                        spaces = spaces+' '
                    sorted_albums[date[:4]] = item
                for item in sorted(sorted_albums,reverse=True):
                    listitem = xbmcgui.ListItem(label=sorted_albums[item])
                    # *srl_2013-06-24_resets* listitem.setProperty('artist',artist_item.getProperty('artist'))
                                            listitem.setProperty('artist',srl_artist)
                    # *srl_2013-06-24_resets* end
                    listitem.setProperty('type','album')
                    listitem.setProperty('album',sorted_albums[item])
                    listitem.setIconImage('DefaultMusicAlbums.png')
                    listitem.setProperty( 'time', item )
                    self.getControl(ARTIST_BROWSER).addItem(listitem)
            elif typ == 'album':
                # *srl_2013-06-24_resets* listitem = xbmcgui.ListItem(label='..  %s - %s'%(artist_item.getProperty('artist'),artist_item.getProperty('album')))
                                    listitem = xbmcgui.ListItem(label='..  %s - %s'%(srl_artist,srl_artist_album))
                # *srl_2013-06-24_resets* end
                listitem.setProperty('type','artist')
                listitem.setIconImage('DefaultFolderBack.png')
                                    # *srl_2013-06-24_resets* listitem.setProperty('artist',artist_item.getProperty('artist'))
                listitem.setProperty('artist',srl_artist)
                # *srl_2013-06-24_resets* end
                self.getControl(ARTIST_BROWSER).addItem(listitem)
                # *srl_2013-06-24_resets* for item in self.client.find('artist',artist_item.getProperty('artist'),'album',artist_item.getProperty('album')):
                                    for item in self.client.find('artist',srl_artist,'album',srl_artist_album):
                # *srl_2013-06-24_resets* end
                    listitem = xbmcgui.ListItem(label=item['title'])
                    # *srl_2013-06-24_resets* listitem.setProperty('artist',artist_item.getProperty('artist'))
                                            listitem.setProperty('artist',srl_artist)
                    # *srl_2013-06-24_resets* end
                    listitem.setProperty('type','file')
                    listitem.setProperty('file',item['file'])
                    # *srl_2013-06-24_resets* listitem.setProperty('album',artist_item.getProperty('album'))
                                            listitem.setProperty('album',srl_artist_album)
                    # *srl_2013-06-24_resets* end
                    listitem.setProperty( 'time', self._format_time(item['time']) )
                    listitem.setIconImage('DefaultAudio.png')
                    self.getControl(ARTIST_BROWSER).addItem(listitem)
        self.getControl(ARTIST_BROWSER).selectItem(select_index)

def _update_file_browser(self,browser_item=None,client=None,back=False):
    select_index = 0
    index = self.getControl(FILE_BROWSER).getSelectedPosition()
    firstitem= None
    if client==None:
        client = self.client
    if browser_item == None:
        self.getControl(FILE_BROWSER).reset()
        dirs = client.lsinfo()
        listitem = xbmcgui.ListItem( label='..')
        listitem.setProperty('directory','')
        listitem.setIconImage('DefaultFolderBack.png')
        firstitem = listitem
    elif browser_item.getProperty('type') == 'file':
        return
    else:
        if index == 0 or back:
            if not self.fb_indexes == []:
                select_index = self.fb_indexes.pop()
        else:
            self.fb_indexes.append(index)
        # *srl_2013-06-24_resets* self.getControl(FILE_BROWSER).reset()
        # uri = browser_item.getProperty('directory')
                    uri = browser_item.getProperty('directory')
                    self.getControl(FILE_BROWSER).reset()
        # *srl_2013-06-24_resets* end
        dirs = client.lsinfo(uri)
        listitem = xbmcgui.ListItem( label='..')
        listitem.setProperty('directory',os.path.dirname(uri))
        listitem.setIconImage('DefaultFolderBack.png')
        firstitem = listitem
    file_items = []
    dir_items = []
    for item in dirs:
        if 'directory' in item:
            listitem = xbmcgui.ListItem( label=os.path.basename(item['directory']))
            listitem.setProperty('type','directory')
            listitem.setProperty('directory',item['directory'])
            listitem.setIconImage('DefaultFolder.png')
            dir_items.append(listitem)
        elif 'file' in item:
            listitem = xbmcgui.ListItem( label=os.path.basename(item['file']))
            listitem.setProperty('type','file')
            listitem.setProperty('directory',os.path.dirname(item['file']))
            listitem.setProperty('file',item['file'])
            listitem.setIconImage('DefaultAudio.png')
            file_items.append(listitem)
    dir_items = sorted(dir_items,key=lambda i:i.getLabel())
    if not firstitem == None:
        dir_items.insert(0,firstitem)
    for i in sorted(file_items,key=lambda i:i.getLabel()):
        dir_items.append(i)
    self.getControl(FILE_BROWSER).addItems(dir_items)
    self.getControl(FILE_BROWSER).selectItem(select_index)
lzoubek commented 10 years ago

This is no longer valid, because currently developed version has completely different codebase