Skip to content

Commit

Permalink
Fix: Parent profiles ordering being reversed / key mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexeh committed Feb 27, 2024
1 parent f625eff commit b7bb155
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions joystick_diagrams/profile_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""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
from joystick_diagrams.db import db_profile_parents, db_profiles
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):
Expand Down Expand Up @@ -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])

Expand Down
6 changes: 5 additions & 1 deletion joystick_diagrams/ui/parent_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b7bb155

Please sign in to comment.