Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_ShowOpenFileDialog callback never called on Linux #9703

Closed
JoelLinn opened this issue May 6, 2024 · 3 comments · Fixed by #9727
Closed

SDL_ShowOpenFileDialog callback never called on Linux #9703

JoelLinn opened this issue May 6, 2024 · 3 comments · Fixed by #9727

Comments

@JoelLinn
Copy link
Contributor

JoelLinn commented May 6, 2024

Using Arch Linux with KDE, dialog shows fine but the callback is never reached, works on Windows.
SDL has most subsystems disabled (in configuration), windowing done by GLFW.

    SDL_DialogFileFilter filters[2] = {
                    {"All", "*"},
                    {nullptr, nullptr},
            };
            if (ImGui::Button("Open File"))
                SDL_ShowOpenFileDialog([](void *userdata, const char * const * filelist, int filter) {
                    if (filelist && filelist[0]) {
                        SDL_Log("File selected: %s", filelist[0]);
                    } else {
                        SDL_Log("File selection failed");
                    }
                }, nullptr, nullptr, filters, nullptr, SDL_TRUE);
@Semphriss
Copy link
Contributor

After some research, it seems that the callback is invoked only during the event management. If you don't have while(SDL_PollEvent(&event)) or something equivalent, you can use SDL_PumpEvents(); in your main loop, and the callback will be invoked at that point.

@slouken Should I add that in the documentation? I'm not sure if SDL always expects to have an event-handling loop, or if functions that need it should be marked as such.


@Kontrabant Probably unrelated, but while searching, I noticed that in DBus_OpenDialog, there are many branches that set an error and return, but don't invoke the callback. Is that normal? I don't want to change the code myself because I don't really understand DBus...

@Kontrabant
Copy link
Contributor

Probably unrelated, but while searching, I noticed that in DBus_OpenDialog, there are many branches that set an error and return, but don't invoke the callback. Is that normal? I don't want to change the code myself because I don't really understand DBus...

Likely just accidental omissions; there should be no problem sending the callback with an error code if the DBus portal errors out at any point.

@slouken
Copy link
Collaborator

slouken commented May 8, 2024

@slouken Should I add that in the documentation? I'm not sure if SDL always expects to have an event-handling loop, or if functions that need it should be marked as such.

Yes, the messagebox and dialog functions could be called without initializing the SDL video subsystem, so if they have a dependency on events that should be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants