mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	make sure the object browser can't crash because when the list data gets bigger than 32kB
This commit is contained in:
		
							parent
							
								
									b7dd49453c
								
							
						
					
					
						commit
						3c4dee4ca7
					
				
					 1 changed files with 20 additions and 6 deletions
				
			
		| 
						 | 
					@ -387,14 +387,26 @@ class BrowserWidget(W.CustomList):
 | 
				
			||||||
			if dataLen >= 6:
 | 
								if dataLen >= 6:
 | 
				
			||||||
				data = theList.LGetCell(dataLen, theCell)
 | 
									data = theList.LGetCell(dataLen, theCell)
 | 
				
			||||||
				iconId, indent, tab = struct.unpack("hhh", data[:6])
 | 
									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:
 | 
									if iconId:
 | 
				
			||||||
					theIcon = Icn.GetCIcon(iconId)
 | 
										try:
 | 
				
			||||||
					rect = (0, 0, 16, 16)
 | 
											theIcon = Icn.GetCIcon(iconId)
 | 
				
			||||||
					rect = Qd.OffsetRect(rect, l, t)
 | 
										except Icn.Error:
 | 
				
			||||||
					rect = Qd.OffsetRect(rect, 0, (theList.cellSize[1] - (rect[3] - rect[1])) / 2)
 | 
											pass
 | 
				
			||||||
					Icn.PlotCIcon(rect, theIcon)
 | 
										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:
 | 
									if len(key) >= 0:
 | 
				
			||||||
					cl, ct, cr, cb = cellRect
 | 
										cl, ct, cr, cb = cellRect
 | 
				
			||||||
| 
						 | 
					@ -411,6 +423,8 @@ class BrowserWidget(W.CustomList):
 | 
				
			||||||
						drawTextCell(value, (cl, ct, cr, cb), ascent, theList)
 | 
											drawTextCell(value, (cl, ct, cr, cb), ascent, theList)
 | 
				
			||||||
			#elif dataLen != 0:
 | 
								#elif dataLen != 0:
 | 
				
			||||||
			#	drawTextCell("???", 3, cellRect, ascent, theList)
 | 
								#	drawTextCell("???", 3, cellRect, ascent, theList)
 | 
				
			||||||
 | 
								else:
 | 
				
			||||||
 | 
									return  # we have bogus data
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			# draw nice dotted line
 | 
								# draw nice dotted line
 | 
				
			||||||
			l, t, r, b = cellRect
 | 
								l, t, r, b = cellRect
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue