Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Tljjz

Pages: [1]
1
Python / Script crashes on exit (sf.RenderWindow, sf.Texture)
« on: November 02, 2013, 02:57:34 pm »
I think I've found a bug in (py)SFML or Python 3.3.
When I run this code (it looks strange, but this is what remained after removing everything that didn't cause the crash):
import sfml as sf

window = sf.RenderWindow(sf.VideoMode(640, 480), 'test')

texture = sf.Texture.from_file('map.png')

window.close()
print('test')
the whole script executes, prints 'test' and then Windows shows a window saying that python.exe has stopped working. However, it doesn't crash in the IDLE python shell, only when I run the script directly.

Deleting the texture before the window is closed fixes everything:
import sfml as sf

window = sf.RenderWindow(sf.VideoMode(640, 480), 'test')

texture = sf.Texture.from_file('map.png')

del texture

window.close()
Looks like the crash is caused by the texture not being deleted before the window is closed.  :o

And this code:
import sfml as sf

window = sf.RenderWindow(sf.VideoMode(640, 480), 'test')

texture = sf.Texture.from_file('map.png')

window.close()
print('test1')
del texture
print('test2')
prints 'test1' and crashes like the first snippet, but unlike the first one it doesn't run fine in IDLE (it enters an infinite loop after print('test1')).

Pages: [1]
anything