From b7bb155843f6e005457d03c332c4f212a0ff8b7e Mon Sep 17 00:00:00 2001 From: Rob <5183487+Rexeh@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:28:41 +0000 Subject: [PATCH] Fix: Parent profiles ordering being reversed / key mismatch --- joystick_diagrams/profile_wrapper.py | 12 ++++++++++-- joystick_diagrams/ui/parent_profiles.py | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/joystick_diagrams/profile_wrapper.py b/joystick_diagrams/profile_wrapper.py index 1151251..5a61689 100644 --- a/joystick_diagrams/profile_wrapper.py +++ b/joystick_diagrams/profile_wrapper.py @@ -1,5 +1,6 @@ """Serves as a wrapper around Plugin Profiles, allowing customisation and restored state of profiles""" +import logging from copy import deepcopy from joystick_diagrams import app_state @@ -7,6 +8,8 @@ from joystick_diagrams.input.profile import Profile_ from joystick_diagrams.plugin_wrapper import PluginWrapper +_logger = logging.getLogger(__name__) + class ProfileWrapper: def __init__(self, profile: Profile_, origin: PluginWrapper): @@ -39,12 +42,17 @@ def get_parents_for_profile(self): """Try get the parents for a given profile from persisted state""" self.parents.clear() parents = db_profiles.get_profile_parents(self.profile_key) + + _logger.debug(f"Parents for profile {self.profile_key} were {parents}") + _state = app_state.AppState() - for parent_key in parents: + for parent_key, _ in parents: + _logger.debug(f"Trying to get parent for {parent_key}") + _wrapper = [ x for x in _state.profile_wrappers if x.profile_key == parent_key ] - + _logger.debug(f"Profiles fond {_wrapper}") if _wrapper: self.parents.append(_wrapper[0]) diff --git a/joystick_diagrams/ui/parent_profiles.py b/joystick_diagrams/ui/parent_profiles.py index a19a8fb..d2fbdd9 100644 --- a/joystick_diagrams/ui/parent_profiles.py +++ b/joystick_diagrams/ui/parent_profiles.py @@ -127,7 +127,11 @@ def save_profile_parent_maps(self): def load_profile_parent_maps(self, profile_wrapper: ProfileWrapper): self.listWidget.clear() - for parent in profile_wrapper.parents: + _logger.debug( + f"Loading profile parent maps for {profile_wrapper.profile_key}: Maps {profile_wrapper.parents}" + ) + + for parent in reversed(profile_wrapper.parents): item = QListWidgetItem( QIcon(parent.profile_origin.icon), parent.profile_name,