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

BadCursor error on shutdown #204

Open
naftali100 opened this issue Apr 18, 2022 · 3 comments
Open

BadCursor error on shutdown #204

naftali100 opened this issue Apr 18, 2022 · 3 comments

Comments

@naftali100
Copy link

naftali100 commented Apr 18, 2022

X Error of failed request:  BadCursor (invalid Cursor parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0x7000017
  Serial number of failed request:  525
  Current serial number in output stream:  531

getting this error when mouse click cause shutdown (clicking imgui button that cause the main loop to break), and sfml window was not closed (easy to fix.. just check if the window is open and close if true...), And call sf::imgui::shutdown().

I thought it worth sharing if someone will get the same error... it took me about a hour to find the problem...

@eliasdaler
Copy link
Contributor

Hello
Please provide a small reproducible example - hard to tell what you mean otherwise, sorry.

@oprypin
Copy link
Member

oprypin commented Apr 20, 2022

I tried to guess what is meant here, and even throw in an extra cursor manipulation, but I don't observe any such error.

diff --git a/examples/minimal/main.cpp b/examples/minimal/main.cpp
index 2c19abd08..d30ae607e 100644
--- a/examples/minimal/main.cpp
+++ b/examples/minimal/main.cpp
@@ -31,7 +31,11 @@ int main() {
         ImGui::ShowDemoWindow();
 
         ImGui::Begin("Hello, world!");
-        ImGui::Button("Look at this pretty button");
+        if (ImGui::Button("Exit")) {
+            window.close();
+        }
+        if (ImGui::IsItemHovered())
+            ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
         ImGui::End();
 
         window.clear();

c++ -I. -I../cimgui/imgui examples/minimal/main.cpp imgui-SFML.cpp ../cimgui/imgui/{imgui_demo.cpp,imgui_widgets.cpp,imgui.cpp,imgui_draw.cpp,imgui_tables.cpp} -lsfml-graphics -lsfml-window -lsfml-system -lGL && ./a.out

Does not reproduce when I click the button

@naftali100
Copy link
Author

i'm sorry for the delay. i forgot about it...
here is a minimal example

int main(){
    sf::RenderWindow m_wim {sf::VideoMode(100, 100), "World"};
    bool ImGuiInit = ImGui::SFML::Init(m_win);
    bool running = true;
    sf::Clock clock;
    while (running) {
        sf::Event event;
        while (m_win.pollEvent(event)) {
            ImGui::SFML::ProcessEvent(m_win, event);
            if(event.type == sf::Event::MouseButtonReleased){
                running = false;
            }
        }
        auto deltaTime = clock.restart();
        ImGui::SFML::Update(m_win, deltaTime);
        m_win.clear();
        ImGui::SFML::Render(m_win);
        m_win.display();

    }
    ImGui::SFML::Shutdown();
}

i got this error in kde on arch

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

No branches or pull requests

3 participants