LayeredDirty.repaint_rect throws TypeError if LayeredDirty clip is not set

Issue #130 resolved
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 (6)

  1. René Dudfield

    Hi,

    thanks for the bug report.

    Any chance of getting a unit test for this? I'm not sure how to reproduce.

  2. 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)
    
  3. Jason Marshall

    fix issue 130 Changes were made in sprite.py, sprite_test.py, and the documentation. I didn't change the documentation on the web though; I don't think I even have the authorization necessary to do that. → 5f97207c3692

  4. Log in to comment