Hugo,
logicalSurface is an object that contain pygame surface I am drawing everything on it and blitting this surface to the pygame screen.
I haven't locked the surface anywhere else, all the others drawing function working fine only blit function gives the problem if and only if I draw the pages quickly by pressing pageUp and pand pageDown.
I have temporary fixed this problem like this, but I want a better solution
def blit(self,screen, logicalSurface, (offsetX,offsetY)):
"""
blit the surface on to the pygamewindow, logicalSurface -> pygame surface
"""
try:
screen.blit (logicalSurface.surface, (-offsetX, -offsetY))
except:
time.sleep(0.1)
self.blit(screen, pygameSurface,(offsetX, offsetY))
Thanks,
Sibtey
On Behalf Of Hugo Arts
What exactly is the difference between logicalSurface and logicalsurface.surface? in draw(), you draw directly on logicalSurface. But after that you blit logicalSurface.surface to the screen.
pygame draw functions will lock/unlock surface automagically IIRC, so the problem is likely with the blit call. Try to find out if either of the surfaces is locked, and if so, try to unlock them. The surface may be locked multiple times, and you must unlock it the same number of times to regain access, so you might need more than one unlock call.
Are you locking these surfaces elsewhere in your code? There may be a bug in that code that causes some surfaces to stay locked when they shouldn't. Remember to call unlock the same amount of times you called lock.
If you don't use lock in your code, there may be a bug in 1.8.0 locking.On Fri, Jun 27, 2008 at 11:16 AM, Sibtey Mehdi <sibteym@xxxxxxxxxxxxxx> wrote:
I am using 1.8.0 packages (march 29 2008). On page Up and Page Down I am calling the drawPage() function.
def drawPage(self, page, logicalSurface):
self.draw(page, logicalSurface)
self.screen.blit (logicalSurface.surface, (-offsetX, -offsetY))
def draw(self, page, logicalSurf):
#draw rect
for rec in page.rects:
self.Pygame.draw.rect(logicalSurf,rec.color,(rec.x1,rec.y1,rec.x2,rec.y2), 1)
#text
for text in page.texts:
#draw text
#lines
for line in page.lines:
self.Pygame.draw.line(logicalSurf, [line.colline.x1,line.y1],[line.x2,line.y2],1)
thanks,
Sibtey
Are you using svn pygame? There have been some changes since 1.8.0 to
the locking code.
Hugo Arts wrote:
> well, if pygame says this is a locking issue, then it is most likely a
> locking issue. If you say unlocking the surface did not fix the problem as
> you said, I don't have another solution with the current supplied
> information.
>
> We'll likely need to see some code before we can figure out the actual
> error.
>
> Hugo
>
> On Fri, Jun 27, 2008 at 8:54 AM, Sibtey Mehdi <sibteym@xxxxxxxxxxxxxx>
> wrote:
>
>
>> Hi
>>
>> I am drawing some graphics page (Text, rect, lines, polygon) on pygame
>> surface, but when I quickly pressing page up and page down my application
>> give the Pygame error "Surfaces must not be locked during blit".
>>
>> I have also unlocked the surface by suface.unlock before blitting but it
>> doesn't solve the problem.
>>
>> So please help me out of this problem
>>
>>
>>
>> Thanks,
>>
>> Sibtey
>>
>>
>>
>>
>
>