# HG changeset patch # User Michael Wagner michael.wagner@gmx.at # Date 1476524038 -7200 # Sat Oct 15 11:33:58 2016 +0200 # Node ID ca2f97cb1dedc2a2172e4be134f2a706c079a808 # Parent 895636193de3319fe8b3d390ec79cae8825acc11 [btech] Resetting mem-extra-settings only when editing previously empty memory. Part of fix for #4121 Attempt to fix #4121 for the driver btech.py following Dan's proposal in http://intrepid.danplanet.com/pipermail/chirp_devel/2016-October/004298.html .
73, Michael Wagner, OE4AMW
diff -r 895636193de3 -r ca2f97cb1ded chirp/drivers/btech.py --- a/chirp/drivers/btech.py Wed Oct 12 18:07:36 2016 -0400 +++ b/chirp/drivers/btech.py Sat Oct 15 11:33:58 2016 +0200 @@ -1043,6 +1043,13 @@ _mem = self._memobj.memory[mem.number] _names = self._memobj.names[mem.number]
+ mem_was_empty = False + # same method as used in get_memory for determining if mem is empty + # doing this BEFORE overwriting it with new values ... + if _mem.get_raw()[0] == "\xFF": + LOG.debug("This mem was empty before") + mem_was_empty = True + # if empty memmory if mem.empty: # the channel itself @@ -1100,16 +1107,24 @@ # extra settings if len(mem.extra) > 0: # there are setting, parse + LOG.debug("Extra-Setting supplied. Setting them.") for setting in mem.extra: setattr(_mem, setting.get_name(), setting.value) else: - # there is no extra settings, load defaults - _mem.spmute = 0 - _mem.optsig = 0 - _mem.scramble = 0 - _mem.bcl = 0 - _mem.pttid = 0 - _mem.scode = 0 + if mem.empty: + LOG.debug("New mem is empty.") + else: + LOG.debug("New mem is NOT empty") + # set extra-settings to default ONLY when apreviously empty or + # deleted memory was edited to prevent errors such as #4121 + if mem_was_empty : + LOG.debug("old mem was empty. Setting default for extras.") + _mem.spmute = 0 + _mem.optsig = 0 + _mem.scramble = 0 + _mem.bcl = 0 + _mem.pttid = 0 + _mem.scode = 0
return mem