简体   繁体   English

SDL_表面分割错误

[英]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. 我有一个DrawMgr类,其中调用了DrawCube函数,另一个类的函数中使用了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. 另一件事是,当我在DrawManager.cpp中调用函数DrawCube时,它不会绘制多维数据集。

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. 编辑:问题是我用e.key.keysym.sym == SDLK_ESCAPE处理了“转义”键,该键捕获了窗口崩溃的所有动作。 The correct way was e.type == SDL_KEYDOWN && e.key.keysym.sym...) 正确的方法是e.type == SDL_KEYDOWN && e.key.keysym.sym...)

SDL_GetWindowSurface documentation says This surface will be freed when the window is destroyed. SDL_GetWindowSurface文档说, 销毁窗口后将释放此表面。 Do not free this surface. 不要释放该表面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM