Closed GoogleCodeExporter closed 8 years ago
I'm having trouble reproducing the bug - the following code runs just fine
under both SVN trunk and 1.1.3:
import pyglet
doc = pyglet.text.decode_attributed('{bold True}Hello{bold False}\n\n\n\n')
doc2 = pyglet.text.decode_attributed('{bold True}Goodbye{bold False}\n\n\n\n')
layout = pyglet.text.layout.IncrementalTextLayout(doc, 100, 10)
layout.document = doc2
Original comment by m.e.w.ol...@gmail.com
on 14 Aug 2009 at 1:31
Your code sample works for me too; I am having a hard time getting a simpler
sample
case that still breaks. Since strip() inexplicably works it's not a big problem
for
me... I'll come back to it if I get the time.
Original comment by ChrisM6794@gmail.com
on 14 Aug 2009 at 3:55
Any code that demonstrates the bug is better than none, even if it is your
whole program. Feel free to email if
you don't want to attach it publically. The obvious @gmail.com
Original comment by m.e.w.ol...@gmail.com
on 14 Aug 2009 at 4:10
Here's a variant of that code sample which generates a similar traceback for me:
import pyglet
doc = pyglet.text.decode_attributed('{bold True}Hello{bold False}\n\n\n\n')
doc2 = pyglet.text.decode_attributed('{bold True}Goodbye{bold False}\n\n\n\n')
layout = pyglet.text.layout.IncrementalTextLayout(doc, 100, 10)
layout.document = doc2
layout.document.delete_text(0, len(layout.document.text))
This is using pyglet 1.2dev (the current hg head) on Mac OS 10.6.3, using Python
2.6.2 installed from python.org. (FYI, I have no problems running that
combination of
pyglet, python, and Mac OS in general, in spite of reported issues with similar
combinations but pyglet 1.1.3, e.g. in issue 438.)
I think the real issue isn't the document replacement or the newlines, but
deleting
all text when there are mixed font styles, since the following simpler example
also
gives a similar traceback:
import pyglet
doc2 = pyglet.text.decode_attributed('{bold True}a{bold False}b')
layout = pyglet.text.layout.IncrementalTextLayout(doc2, 100, 10)
layout.document.delete_text(0, len(layout.document.text))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/text/document.py",
line 445, in delete_text
self.dispatch_event('on_delete_text', start, end)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/event.py",
line 340, in dispatch_event
if handler(*args):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/text/layout.py",
line 1804, in on_delete_text
self._update()
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/text/layout.py",
line 1837, in _update
font = self.document.get_font(0, dpi=self._dpi)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/text/document.py",
line 660, in get_font
return iter[position]
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/text/document.py",
line 719, in __getitem__
font_name, font_size, bold, italic = self.zip_iter[index]
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/text/runlist.py",
line 403, in __getitem__
return [i[index] for i in self.range_iterators]
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p
yglet/text/runlist.py",
line 293, in __getitem__
self.start, self.end, self.value = self.next()
StopIteration
A possible clue to the cause (but no guarantee, since it's different code): in a
larger editor example (not posted here), doing the same thing manually gets a
similar
traceback, and a subsequent click in the text widget gets the following
additional
traceback:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 295, in 'calling callback function'
File "/Applications/pyglet/pyglet-hg/pyglet/window/carbon/__init__.py", line 797,
in _on_mouse_down
self.dispatch_event('on_mouse_press', x, y, button, modifiers)
File "/Applications/pyglet/pyglet-hg/pyglet/window/__init__.py", line 1150, in
dispatch_event
if EventDispatcher.dispatch_event(self, *args) != False:
File "/Applications/pyglet/pyglet-hg/pyglet/event.py", line 369, in dispatch_event
event_type, args, getattr(self, event_type))
File "/Applications/pyglet/pyglet-hg/pyglet/event.py", line 365, in dispatch_event
if getattr(self, event_type)(*args):
File "edithack1.py", line 363, in on_mouse_press
self.focus.caret.on_mouse_press(x, y, button, modifiers)
File "/Applications/pyglet/pyglet-hg/pyglet/text/caret.py", line 552, in on_mouse_press
self.move_to_point(x, y)
File "/Applications/pyglet/pyglet-hg/pyglet/text/caret.py", line 322, in move_to_point
line = self._layout.get_line_from_point(x, y)
File "/Applications/pyglet/pyglet-hg/pyglet/text/layout.py", line 2272, in
get_line_from_point
if y > line.y + line.descent:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
(Since this provides a repeatable example, I'm unblocking the bug. I'm also
revising
the summary to fit my guess about the true cause.)
Original comment by ores...@gmail.com
on 27 Apr 2010 at 6:46
Oops, I acted too fact -- it looks like the problem I posted is a duplicate of
open
issue 471 (which is itself a duplicate of improperly closed issue 241). Also,
the
traceback I posted ends similarly to the original traceback, but doesn't look
similar
at intermediate points, so it may or may not be the same bug.
I will reopen issue 241, officially mark issue 471 as a duplicate of issue 241,
and
post my new info into issue 241. I'll change this issue's status and summary
(well, I
can't figure out how to find the old summary!) back to what they were
originally, and
let this issue's owner decide what to do further on it.
Original comment by ores...@gmail.com
on 27 Apr 2010 at 7:00
(FYI, I ended up leaving issue 241 closed and not marking issue 471 as a
duplicate of
it -- see their comments for details. It is still quite possible that this
issue,
whatever it is, will be fixed when 471 is fixed.)
Original comment by ores...@gmail.com
on 27 Apr 2010 at 10:33
This issue was closed by revision dd518f80b6e3.
Original comment by useboxnet
on 17 Jul 2013 at 7:47
I backported the fix from default:
http://code.google.com/p/pyglet/source/detail?r=dd518f80b6e3ffe5846189dbc647af66
3ce7e5aa&name=pyglet-1.1-maintenance
Original comment by useboxnet
on 17 Jul 2013 at 7:52
Original issue reported on code.google.com by
ChrisM6794@gmail.com
on 6 Jul 2009 at 5:54