Issue #130 resolved

LayeredDirty.repaint_rect throws TypeError if LayeredDirty clip is not set

Christopher Foo
created an issue

Python 3.2.3

changeset: 3106:e6b5ebf91ac4

Traceback: {{{ File "/home/chris/Documents/programming/<snip>/controllers/scene.py", line 49, in draw self._scene.repaint_rect(pygame.Rect(0.0, 0.0, width, height)) File "/usr/local/lib/python3.2/dist-packages/pygame/sprite.py", line 1164, in repaint_rect self.lostsprites.append(screen_rect.clip(self._clip)) TypeError: Argument must be rect style object }}}

I have an instance of {{{LayeredDirty}}} and I'm calling {{{ repaint_rect }}} after a VIDEORESIZE event so that the entire screen is redrawn. However, it throws an exception if I don't set a clip. Debugging shows {{{self._clip}}} is {{{None}}}.

As well, I found that the documentation could clarify that {{{ repaint_rect }}} will respect any clip that was set and that {{{ repaint_rect }}} doesn't do any explicit drawing.

Comments (5)

  1. Christopher Foo reporter

    Hi, after writing a small test, i found it’s actually quite simple to reproduce than how I explained it.

    This isn’t much of a unit test but it shows the bug if the clip is not set. The test_repaint_rect currently gives an error.

    class LayeredDirtyRepaintRectBugTest(unittest.TestCase):
        def test_repaint_rect(self):
            group = pygame.sprite.LayeredDirty()
            surface = pygame.Surface((100, 100))
    
            group.repaint_rect(pygame.Rect(0, 0, 100, 100))
            group.draw(surface)
    
        def test_repaint_rect_with_clip(self):
            group = pygame.sprite.LayeredDirty()
            surface = pygame.Surface((100, 100))
    
            group.set_clip(pygame.Rect(0, 0, 100, 100))
            group.repaint_rect(pygame.Rect(0, 0, 100, 100))
            group.draw(surface)
    
  2. Log in to comment