Closed Dlinuigh closed 3 weeks ago
Oh, I'm using SDL3 from main branch built on an Arch Linux Machine. The built date is about 19 April.
Does reordering the functions help?
for(auto f : font_lut){
TTF_CloseFont(f.second);
}
TTF_Quit();
SDL_DestroyRenderer(render);
SDL_DestroyWindow(window);
SDL_QuitSubSystem(SDL_INIT_EVENTS); // <---
SDL_QuitSubSystem(SDL_INIT_VIDEO); // <---
SDL_Quit();
Do you have a simple example we can run here to reproduce the problem?
I am trying to write a short code example, sorry for the late reply.
Does reordering the functions help?
for(auto f : font_lut){ TTF_CloseFont(f.second); } TTF_Quit(); SDL_DestroyRenderer(render); SDL_DestroyWindow(window); SDL_QuitSubSystem(SDL_INIT_EVENTS); // <--- SDL_QuitSubSystem(SDL_INIT_VIDEO); // <--- SDL_Quit();
It seems no difference, but I found the break point is still around SDL_DestroyWindow
line.
ok, I complete the example
test_sdl.zip well, this example is complied with meson, and as a subproject.
Press the white button in the top left corner. I have tested this in a clean environment, though not a literal one. And
C++ compiler for the host machine: ccache c++ (gcc 14.1.1 "c++ (GCC) 14.1.1 20240507")
C++ linker for the host machine: c++ ld.bfd 2.42.0
And this is the meson.build file content for the latter test.
project('SDL_Test_SetKeyBoardFocus', 'cpp',
version : '0.1',
default_options : ['warning_level=3', 'cpp_std=c++14'])
deps = [
dependency('sdl3'),
dependency('sdl3-ttf')
]
executable('SDL_Test_SetKeyBoardFocus',
'test_sdl.cpp',dependencies:deps,
install : true)
So if you need any other information related, just leave a message.
I found that this is actually a Wayland only problem, Gnome with xorg will not show this WARN.
Lately, I've encountered numerous issues with Wayland compatibility, which has left me feeling quite tense.
The sample code has several problems:
#include <SDL3/SDL.h>
#include <sys/types.h>
class Test
{
SDL_Window *window;
SDL_Renderer *render;
SDL_Event event;
public:
Test()
{
SDL_Init(SDL_INIT_EVENTS);
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow("Test", 800, 600, SDL_WINDOW_BORDERLESS);
render = SDL_CreateRenderer(window, NULL, 0);
}
bool in_btn()
{
float mouse_x, mouse_y;
SDL_GetMouseState(&mouse_x, &mouse_y);
return 0 < mouse_x && 0 + 64 > mouse_x && 0 < mouse_y &&
32 > mouse_y;
}
bool handle()
{
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_EVENT_MOUSE_BUTTON_DOWN:
if (event.button.button == SDL_BUTTON_LEFT && in_btn()) {
return false;
}
break;
case SDL_EVENT_KEY_DOWN:
if (event.key.keysym.sym == SDLK_q) {
return false;
}
break;
}
}
return true;
}
void clean()
{
SDL_DestroyRenderer(render);
SDL_DestroyWindow(window);
SDL_QuitSubSystem(SDL_INIT_EVENTS); // <---
SDL_QuitSubSystem(SDL_INIT_VIDEO); // <---
SDL_Quit();
}
void present()
{
SDL_SetRenderTarget(render, NULL);
SDL_SetRenderDrawColor(render, 255, 255, 255, 255);
SDL_FRect btn = { 0, 0, (float)64, (float)32 };
SDL_RenderFillRect(render, &btn);
SDL_RenderPresent(render);
}
};
int main()
{
Test test;
while (test.handle()) {
test.present();
}
test.clean();
return 0;
}
With this on the current version of SDL3, it runs correctly.
I compiled and run the code above, it still has the problem on Wayland. So do you run the code in a xorg environment?
And I agree that this is the problem of mouse event for this won't happen when I quit with keyboard down event.
Anyway I will compile the latest version of SDL3 to test, thank you.
Ok, the problem has been solved. Thank you again.
This WARN show every time when trying to quit SDL; And the SDL_keyboard.c file does not exist on my computer. Although this WARN can ignore, but I still feel uncomfortable.
I think the problem may exist between this code. Because the
break
button tells me. I'm not sure if this is an SDL concern, but I think I might seek help here.