Skip to content

Commit

Permalink
Fix pasting memories past end of range
Browse files Browse the repository at this point in the history
The memory editor will fail with a 'KeyError: N' error if the user
attempts to paste more memories than will fit. This makes us not
choke, stop when we get to the end, and report to the user (unless
the memories that don't fit are empty).

Fixes #11510
  • Loading branch information
kk7ds committed Aug 31, 2024
1 parent 4933cc7 commit b02e7af
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions chirp/wxui/memedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,12 @@ def _cb_paste_memories(self, payload, row=None):

overwrite = []
for i in range(len(mems)):
mem = self._memory_cache[row + i]
try:
mem = self._memory_cache[row + i]
except KeyError:
# No more memories in the target. This will be handled/reported
# in the actual paste loop below.
break
if not mem.empty:
overwrite.append(mem.extd_number or mem.number)

Expand Down Expand Up @@ -2015,7 +2020,20 @@ def _cb_paste_memories(self, payload, row=None):
errormsgs = []
modified = False
for mem in mems:
existing = self._memory_cache[row]
try:
existing = self._memory_cache[row]
except KeyError:
if not mem.empty:
LOG.debug('Not pasting to row %i beyond end of memory',
row)
errormsgs.append(
(mem, _('No more space available; '
'some memories were not applied')))
break
else:
# Don't complain about empty memories past the end of the
# current radio's memory upper bound.
continue
number = self.row2mem(row)
# We need to disable immutable checking while we reassign these
# numbers. This might be a flag that we should be copying things
Expand Down

0 comments on commit b02e7af

Please sign in to comment.