Fix crashes in media settings (Bug #908252)

This commit is contained in:
Jon Tibble 2011-12-31 17:37:56 +00:00
parent 768c099971
commit fb34a3e86d

View File

@ -36,6 +36,7 @@ class MediaTab(SettingsTab):
""" """
def __init__(self, parent, title, visible_title, media_players, icon_path): def __init__(self, parent, title, visible_title, media_players, icon_path):
self.mediaPlayers = media_players self.mediaPlayers = media_players
self.savedUsedPlayers = None
SettingsTab.__init__(self, parent, title, visible_title, icon_path) SettingsTab.__init__(self, parent, title, visible_title, icon_path)
def setupUi(self): def setupUi(self):
@ -138,6 +139,7 @@ class MediaTab(SettingsTab):
if player not in self.usedPlayers: if player not in self.usedPlayers:
self.usedPlayers.append(player) self.usedPlayers.append(player)
else: else:
if player in self.usedPlayers:
self.usedPlayers.takeAt(self.usedPlayers.indexOf(player)) self.usedPlayers.takeAt(self.usedPlayers.indexOf(player))
self.updatePlayerList() self.updatePlayerList()
@ -146,7 +148,7 @@ class MediaTab(SettingsTab):
for player in self.usedPlayers: for player in self.usedPlayers:
if player in self.playerCheckBoxes.keys(): if player in self.playerCheckBoxes.keys():
if len(self.usedPlayers) == 1: if len(self.usedPlayers) == 1:
# at least one media player have to stay active # At least one media player has to stay active
self.playerCheckBoxes[u'%s' % player].setEnabled(False) self.playerCheckBoxes[u'%s' % player].setEnabled(False)
else: else:
self.playerCheckBoxes[u'%s' % player].setEnabled(True) self.playerCheckBoxes[u'%s' % player].setEnabled(True)
@ -169,14 +171,20 @@ class MediaTab(SettingsTab):
self.usedPlayers.move(currentRow, currentRow + 1) self.usedPlayers.move(currentRow, currentRow + 1)
def load(self): def load(self):
if self.savedUsedPlayers:
self.usedPlayers = self.savedUsedPlayers
self.savedUsedPlayers = None
self.usedPlayers = QtCore.QSettings().value( self.usedPlayers = QtCore.QSettings().value(
self.settingsSection + u'/players', self.settingsSection + u'/players',
QtCore.QVariant(u'webkit')).toString().split(u',') QtCore.QVariant(u'webkit')).toString().split(u',')
self.savedUsedPlayers = self.usedPlayers
for key in self.mediaPlayers: for key in self.mediaPlayers:
player = self.mediaPlayers[key] player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name] checkbox = self.playerCheckBoxes[player.name]
if player.available and player.name in self.usedPlayers: if player.available and player.name in self.usedPlayers:
checkbox.setChecked(True) checkbox.setChecked(True)
else:
checkbox.setChecked(False)
self.updatePlayerList() self.updatePlayerList()
self.overridePlayerCheckBox.setChecked(QtCore.QSettings().value( self.overridePlayerCheckBox.setChecked(QtCore.QSettings().value(
self.settingsSection + u'/override player', self.settingsSection + u'/override player',