[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] pgu broken with pygame 1.8.1release ? - patch for one bug(crash)



Knowing that a number of pygame games used pgu, and on top of that pyweek is near, I take the liberty to re-post at pygame-users.
 
pgu broken with pygame 1.8.1release ? - patch for one bug(crash)
Nine of the demos crash with the same (except script name) traceback:

Traceback (most recent call last):
  File "F:\cla 2008 08 13\trunk\examples\gui11.py", line 67, in ?
    app.run(main)
  File "..\pgu\gui\app.py", line 207, in run
    self.loop()
  File "..\pgu\gui\app.py", line 163, in loop
    us = self.update(s)
  File "..\pgu\gui\app.py", line 188, in update
    self.paint(screen)
  File "..\pgu\gui\app.py", line 174, in paint
    container.Container.paint(self,screen)
  File "..\pgu\gui\container.py", line 100, in paint
    w.paint(sub)
  File "..\pgu\gui\theme.py", line 288, in func
    r = m(surface.subsurface(s,w._rect_content))
  File "..\pgu\gui\container.py", line 100, in paint
    w.paint(sub)
  File "..\pgu\gui\theme.py", line 288, in func
    r = m(surface.subsurface(s,w._rect_content))
  File "..\pgu\gui\container.py", line 100, in paint
    w.paint(sub)
  File "..\pgu\gui\theme.py", line 288, in func
    r = m(surface.subsurface(s,w._rect_content))
  File "..\pgu\gui\container.py", line 100, in paint
    w.paint(sub)
  File "..\pgu\gui\theme.py", line 286, in func
    w.background.paint(surface.subsurface(s,w._rect_border))
  File "..\pgu\gui\theme.py", line 473, in paint
    self.theme.render(s,v,r)
  File "..\pgu\gui\theme.py", line 404, in render
    ww,hh=box.get_width()/3,box.get_height()/3
AttributeError: 'pygame.Color' object has no attribute 'get_width'

The offending scripts are:
gui6.py
gui11.py
gui13.py
gui15.py
gui16.py
gui17.py

html2.py
html3.py
html5.py

Besides, gui9.py don't crash but misbehaves: with pygame 1.7.1 you can draw boxes and circles but with pygame 1.8.1release no boxes and circles.

I tried pgu '0.10.6' ( checked out from imitation pickles, rev 38 ), also pgu-0.10.6.tar.gz from sourceforge and pgu 0.10.3, same results.

The demos run fine with pygame 1.7.1

Extra info:
win xp + sp2, python 2.4.3

Okay, found the problem for the crashes: will manifest in widgets with solid color background.
Cause: color was a tuple, now it is a pygame.colors.Color instance. See patch for details.
A patch (against pgu svn imitation pickles r38) is attached.
It is pygame 1.7.1 and 1.8.1 compatible.

The other problem (gui9.py misbehaving with pygame 1.8.1release) remains.


--
claxo

-------------------------

Index: theme.py
===================================================================
--- theme.py	(revisi¢n: 38)
+++ theme.py	(copia de trabajo)
@@ -396,7 +396,7 @@
         
         if box == 0: return
         
-        if type(box) == tuple:
+        if not isinstance(box,pygame.Surface):
             s.fill(box,r)
             return
         
@@ -467,7 +467,7 @@
     def paint(self,s):
         r = pygame.Rect(0,0,s.get_width(),s.get_height())
         v = self.value.style.background
-        if type(v) == tuple:
+        if not isinstance(v,pygame.Surface):
             s.fill(v)
         else: 
             self.theme.render(s,v,r)