{libcanvas/Canvas,libgui/GuiCanvasPanel}.py: neither commit nor draw patches referencing cells outside of the current map.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-08 19:04:27 +02:00
parent 6bd8815640
commit f6559de704
2 changed files with 15 additions and 10 deletions

View File

@ -16,15 +16,20 @@ class Canvas():
# {{{ dispatchPatch(self, isCursor, patch, commitUndo=True) # {{{ dispatchPatch(self, isCursor, patch, commitUndo=True)
def dispatchPatch(self, isCursor, patch, commitUndo=True): def dispatchPatch(self, isCursor, patch, commitUndo=True):
patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell]; if (patch[0] >= self.size[0]) \
if isCursor: or (patch[1] >= self.size[1]):
self.journal.pushCursor(patchDelta) return False
else: else:
if commitUndo: patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
if not self.dirtyJournal: if isCursor:
self.journal.pushDeltas([], []); self.dirtyJournal = True; self.journal.pushCursor(patchDelta)
self.journal.updateCurrentDeltas(patch, patchDelta) else:
self._commitPatch(patch) if commitUndo:
if not self.dirtyJournal:
self.journal.pushDeltas([], []); self.dirtyJournal = True;
self.journal.updateCurrentDeltas(patch, patchDelta)
self._commitPatch(patch)
return True
# }}} # }}}
# {{{ resize(self, newSize, commitUndo=True) # {{{ resize(self, newSize, commitUndo=True)
def resize(self, newSize, commitUndo=True): def resize(self, newSize, commitUndo=True):

View File

@ -31,8 +31,8 @@ class GuiCanvasPanel(wx.Panel):
# }}} # }}}
# {{{ dispatchPatch(self, eventDc, isCursor, patch) # {{{ dispatchPatch(self, eventDc, isCursor, patch)
def dispatchPatch(self, eventDc, isCursor, patch): def dispatchPatch(self, eventDc, isCursor, patch):
self.canvas.dispatchPatch(isCursor, patch, False if isCursor else True) if self.canvas.dispatchPatch(isCursor, patch, False if isCursor else True):
self._drawPatch(eventDc, isCursor, patch) self._drawPatch(eventDc, isCursor, patch)
# }}} # }}}
# {{{ resize(self, newSize, commitUndo=True) # {{{ resize(self, newSize, commitUndo=True)
def resize(self, newSize, commitUndo=True): def resize(self, newSize, commitUndo=True):