Simeon Godinyachki
Simeon Godinyachki

Reputation: 21

SDL_Surface Segmentation Fault

so here's my problem(s). I have a class DrawMgr in which function DrawCube I call, my other class' function draw in which I use SDL_Surface. My main problem is that when I start moving the mouse over the window I created after some time it gives a segmentation fault, which when I backtrace says it has something to do with freeing the surface. The other thing is when I call the function DrawCube in the DrawManager.cpp it doesn't draw the cube.

EDIT: The problem was that I handled the "Escape" key with e.key.keysym.sym == SDLK_ESCAPE, which captured all movement within the window which made it crash. The correct way was e.type == SDL_KEYDOWN && e.key.keysym.sym...)

Upvotes: 0

Views: 433

Answers (1)

keltar
keltar

Reputation: 18409

SDL_GetWindowSurface documentation says This surface will be freed when the window is destroyed. Do not free this surface.

Upvotes: 1

Related Questions