]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Fix common key properties not applying when property is absent
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 12 Aug 2016 14:13:24 +0000 (16:13 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 12 Aug 2016 14:13:24 +0000 (16:13 +0200)
music_sampler/mapping.py

index a04c2f6ec550021dacc65ec891a4d4e7a5f6f731..99c99773b7751c213eb2546871fd3d2dfbb9d229 100644 (file)
@@ -6,6 +6,7 @@ from kivy.clock import Clock
 import threading
 import yaml
 import sys
+import copy
 from collections import defaultdict
 
 from transitions.extensions import HierarchicalMachine as Machine
@@ -355,12 +356,13 @@ class Mapping(RelativeLayout):
                 isinstance(config['key_properties'], dict):
             common_key_properties = config['key_properties']['common']
             include_aliases(common_key_properties, aliases)
+            check_key_property(common_key_properties, 'common')
         elif 'common' in config['key_properties']:
             warn_print("'common' key in key_properties is not a hash, ignored")
 
         key_properties = defaultdict(lambda: {
                 "actions":    [],
-                "properties": {},
+                "properties": copy.deepcopy(common_key_properties),
                 "files":      []
             })
 
@@ -376,12 +378,9 @@ class Mapping(RelativeLayout):
                 continue
 
             include_aliases(key_prop, aliases)
-            for _key in common_key_properties:
-                key_prop.setdefault(_key, common_key_properties[_key])
-
             check_key_property(key_prop, key)
 
-            key_properties[key]["properties"] = key_prop
+            key_properties[key]["properties"].update(key_prop)
 
         for mapped_key in check_mapped_keys(config):
             for index, action in enumerate(check_mapped_key(