Correctly clear window variables e.g. on user switch

This commit is contained in:
croneter 2019-04-17 15:39:44 +02:00
parent 37f1bddf9d
commit 9b45a84d7e

View file

@ -626,6 +626,9 @@ def _sync_from_pms(pick_libraries):
# Remove the section itself # Remove the section itself
old_section.remove() old_section.remove()
# Clear all existing window vars because we did NOT remove them with the
# command section.remove()
clear_window_vars()
# Time to write the sections to Kodi # Time to write the sections to Kodi
for section in sections: for section in sections:
section.to_kodi() section.to_kodi()
@ -638,14 +641,17 @@ def _sync_from_pms(pick_libraries):
def _clear_window_vars(index): def _clear_window_vars(index):
node = 'Plex.nodes.%s' % index node = 'Plex.nodes.%s' % index
utils.window('%s.index' % node, clear=True)
utils.window('%s.title' % node, clear=True) utils.window('%s.title' % node, clear=True)
utils.window('%s.type' % node, clear=True) utils.window('%s.type' % node, clear=True)
utils.window('%s.content' % node, clear=True) utils.window('%s.content' % node, clear=True)
utils.window('%s.path' % node, clear=True) utils.window('%s.path' % node, clear=True)
utils.window('%s.id' % node, clear=True) utils.window('%s.id' % node, clear=True)
utils.window('%s.addon_path' % node, clear=True) utils.window('%s.addon_index' % node, clear=True)
# Just clear everything here, ignore the plex_type
for typus in (x[0] for y in nodes.NODE_TYPES.values() for x in y):
for kind in WINDOW_ARGS: for kind in WINDOW_ARGS:
node = 'Plex.nodes.%s.%s' % (index, kind) node = 'Plex.nodes.%s.%s.%s' % (index, typus, kind)
utils.window(node, clear=True) utils.window(node, clear=True)
@ -653,7 +659,7 @@ def clear_window_vars():
""" """
Removes all references to sections stored in window vars 'Plex.nodes...' Removes all references to sections stored in window vars 'Plex.nodes...'
""" """
LOG.info('Clearing all the Plex video node variables') LOG.debug('Clearing all the Plex video node variables')
number_of_nodes = int(utils.window('Plex.nodes.total') or 0) number_of_nodes = int(utils.window('Plex.nodes.total') or 0)
utils.window('Plex.nodes.total', clear=True) utils.window('Plex.nodes.total', clear=True)
for index in range(number_of_nodes): for index in range(number_of_nodes):