fix bluescreen ('NoneType' object has no attribute 'getPath')
[enigma2.git] / lib / python / Screens / ChannelSelection.py
index 3cd5968b45f37076fe3d513cece87a60d609d248..8d09f01fc24c5df6168979f921c36de462efbc84 100644 (file)
@@ -54,7 +54,8 @@ class ChannelContextMenu(Screen):
                        })
                menu = [ ]
 
-               inBouquetRootList = csel.getRoot().getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
+               current_root = csel.getRoot()
+               inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
                inBouquet = csel.getMutableList() is not None
                haveBouquets = csel.bouquet_root.getPath().find('FROM BOUQUET "bouquets.') != -1
 
@@ -67,11 +68,11 @@ class ChannelContextMenu(Screen):
                                                menu.append((_("add service to favourites"), self.addServiceToBouquetSelected))
                                elif haveBouquets:
                                        if not inBouquet and csel.getCurrentSelection().getPath().find("PROVIDERS") == -1:
-                                               menu.append((_("copy to favourites"), csel.copyCurrentToBouquetList))
+                                               menu.append((_("copy to favourites"), self.copyCurrentToBouquetList))
                                if inBouquet:
                                        menu.append((_("remove service"), self.removeCurrentService))
                        elif haveBouquets:
-                               menu.append((_("remove bouquet"), csel.removeBouquet))
+                               menu.append((_("remove bouquet"), self.removeBouquet))
 
                if inBouquet: # current list is editable?
                        if not csel.bouquet_mark_edit:
@@ -342,7 +343,10 @@ class ChannelSelectionEdit:
                self.mutableList = None
                self.setTitle(self.saved_title)
                self.saved_title = None
-               self.servicePath = self.savedPath[:]
+               # self.servicePath is just a reference to servicePathTv or Radio...
+               # so we never ever do use the asignment operator in self.servicePath
+               del self.servicePath[:] # remove all elements
+               self.servicePath += self.savedPath # add saved elements
                del self.savedPath
                self.setRoot(self.servicePath[len(self.servicePath)-1])
 
@@ -371,7 +375,6 @@ class ChannelSelectionEdit:
                        if not mutableList.addService(self.servicelist.getCurrent()):
                                self.bouquetNumOffsetCache = { }
                                mutableList.flushChanges()
-               self.close()
 
        def toggleMoveMode(self):
                if self.movemode:
@@ -436,7 +439,9 @@ class ChannelSelectionBase(Screen):
 
                self.servicePathTV = [ ]
                self.servicePathRadio = [ ]
-               self.servicePath = None
+               self.servicePath = [ ]
+
+               self.mode = MODE_TV
 
                self.pathChangedDisabled = False
 
@@ -459,7 +464,7 @@ class ChannelSelectionBase(Screen):
                                "7": self.keyNumberGlobal,
                                "8": self.keyNumberGlobal,
                                "9": self.keyNumberGlobal,
-                               "0": self.keyNumberGlobal
+                               "0": self.keyNumber0
                        })
 
        def appendDVBTypes(self, ref):
@@ -784,6 +789,27 @@ class ChannelSelectionBase(Screen):
                        return bouquets
                return None
 
+       def keyNumber0(self, num):
+               if len(self.servicePath) > 1:
+                       self.keyGoUp()
+               else:
+                       self.keyNumberGlobal(num)
+
+       def keyGoUp(self):
+               if len(self.servicePath) > 1:
+                       if self.isBasePathEqual(self.bouquet_root):
+                               self.showFavourites()
+                       else:
+                               ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
+                               if self.isBasePathEqual(ref):
+                                       self.showSatellites()
+                               else:
+                                       ref = eServiceReference('%s FROM PROVIDERS ORDER BY name'%(self.service_types))
+                                       if self.isBasePathEqual(ref):
+                                               self.showProviders()
+                                       else:
+                                               self.showAllServices()
+
 HISTORYSIZE = 20
 
 class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
@@ -847,18 +873,19 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        self.session.nav.playService(nref)
                self.saveRoot()
                self.saveChannel()
-               tmp=self.servicePath[:]
-               tmp.append(nref)
-               try:
-                       del self.history[self.history_pos+1:]
-               except:
-                       pass
-               self.history.append(tmp)
-               hlen = len(self.history)
-               if hlen > HISTORYSIZE:
-                       del self.history[0]
-                       hlen -= 1
-               self.history_pos = hlen-1
+               if self.servicePath is not None:
+                       tmp=self.servicePath[:]
+                       tmp.append(nref)
+                       try:
+                               del self.history[self.history_pos+1:]
+                       except:
+                               pass
+                       self.history.append(tmp)
+                       hlen = len(self.history)
+                       if hlen > HISTORYSIZE:
+                               del self.history[0]
+                               hlen -= 1
+                       self.history_pos = hlen-1
 
        def historyBack(self):
                hlen = len(self.history)
@@ -875,7 +902,8 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
        def setHistoryPath(self):
                path = self.history[self.history_pos][:]
                ref = path.pop()
-               self.servicePath = path
+               del self.servicePath[:]
+               self.servicePath += path
                self.saveRoot()
                plen = len(path)
                root = path[plen-1]