Skip to content

Commit

Permalink
make sure the object browser can't crash because when the list data g…
Browse files Browse the repository at this point in the history
…ets bigger than 32kB
  • Loading branch information
justvanrossum committed Sep 16, 2002
1 parent b7dd494 commit 3c4dee4
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Mac/Tools/IDE/PyBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,26 @@ def myDrawCell(self, onlyHilite, selected, cellRect, theCell,
if dataLen >= 6:
data = theList.LGetCell(dataLen, theCell)
iconId, indent, tab = struct.unpack("hhh", data[:6])
key, value = data[6:].split("\t", 1)
try:
key, value = data[6:].split("\t", 1)
except ValueError:
# bogus data, at least don't crash.
indent = 0
tab = 0
iconId = 0
key = ""
value = data[6:]

if iconId:
theIcon = Icn.GetCIcon(iconId)
rect = (0, 0, 16, 16)
rect = Qd.OffsetRect(rect, l, t)
rect = Qd.OffsetRect(rect, 0, (theList.cellSize[1] - (rect[3] - rect[1])) / 2)
Icn.PlotCIcon(rect, theIcon)
try:
theIcon = Icn.GetCIcon(iconId)
except Icn.Error:
pass
else:
rect = (0, 0, 16, 16)
rect = Qd.OffsetRect(rect, l, t)
rect = Qd.OffsetRect(rect, 0, (theList.cellSize[1] - (rect[3] - rect[1])) / 2)
Icn.PlotCIcon(rect, theIcon)

if len(key) >= 0:
cl, ct, cr, cb = cellRect
Expand All @@ -411,6 +423,8 @@ def myDrawCell(self, onlyHilite, selected, cellRect, theCell,
drawTextCell(value, (cl, ct, cr, cb), ascent, theList)
#elif dataLen != 0:
# drawTextCell("???", 3, cellRect, ascent, theList)
else:
return # we have bogus data

# draw nice dotted line
l, t, r, b = cellRect
Expand Down

0 comments on commit 3c4dee4

Please sign in to comment.