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

Window is destroyed multiple times #1101

Closed
psychon opened this issue Jul 22, 2020 · 0 comments · Fixed by #1103
Closed

Window is destroyed multiple times #1101

psychon opened this issue Jul 22, 2020 · 0 comments · Fixed by #1103
Labels
bug does not behave the way it is supposed to shell/x11 concerns the X11 backend

Comments

@psychon
Copy link
Contributor

psychon commented Jul 22, 2020

Running cd druid-shell && cargo run --example invalidate --features=x11 with the following patch and then closing the window results in the following output

diff --git a/druid-shell/src/platform/x11/window.rs b/druid-shell/src/platform/x11/window.rs
index f2def4a..c0b958e 100644
--- a/druid-shell/src/platform/x11/window.rs
+++ b/druid-shell/src/platform/x11/window.rs
@@ -510,6 +510,7 @@ impl Window {
 
     /// Start the destruction of the window.
     pub fn destroy(&self) {
+        println!("Destroy");
         log_x11!(self.app.connection().destroy_window(self.id));
     }
 
INFO  [druid_shell::platform::x11::application] X server supports Present version 1.0
INFO  [druid_shell::platform::x11::application] X server supports XFIXES version 5.0
Destroy
Destroy
ERROR [druid_shell::platform::x11::application] Error handling event: X11 error Window(ValueError { error_code: 3, sequence: 270, bad_value: 33554433, minor_opcode: 0, major_opcode: 4 })

The X11 error obviously occurs because druid-shell tries to destroy the window twice. The second destroy fails since the window is already gone. So, I guess something needs to keep track of the "destroyed" state and prevent.... basically any new interaction with the window. All functions need to do the equivalent of if destroyed { return; }.

Relevant backtraces:

Breakpoint 1, druid_shell::platform::x11::window::Window::destroy (self=0x555555746da0)
    at druid-shell/src/platform/x11/window.rs:513
513	        println!("Destroy");
(gdb) bt
#0  druid_shell::platform::x11::window::Window::destroy (self=0x555555746da0) at druid-shell/src/platform/x11/window.rs:513
#1  0x00005555555d331a in druid_shell::platform::x11::window::Window::close (self=0x555555746da0)
    at druid-shell/src/platform/x11/window.rs:642
#2  0x00005555555d5c8f in druid_shell::platform::x11::window::Window::handle_client_message
    (self=0x555555746da0, client_message=0x7fffffffda84) at druid-shell/src/platform/x11/window.rs:888
#3  0x0000555555588855 in druid_shell::platform::x11::application::Application::handle_event
    (self=0x7fffffffe190, ev=0x7fffffffda80) at druid-shell/src/platform/x11/application.rs:313
#4  0x000055555558a29a in druid_shell::platform::x11::application::Application::run_inner (self=...)
    at druid-shell/src/platform/x11/application.rs:409
#5  0x000055555558b380 in druid_shell::platform::x11::application::Application::run (self=..., _handler=...)
    at druid-shell/src/platform/x11/application.rs:450
#6  0x00005555555806f8 in druid_shell::application::Application::run (self=..., handler=...)
    at druid-shell/src/application.rs:153
#7  0x000055555557a647 in invalidate::main () at druid-shell/examples/invalidate.rs:102
Breakpoint 1, druid_shell::platform::x11::window::Window::destroy (self=0x555555746da0)
    at druid-shell/src/platform/x11/window.rs:513
513	        println!("Destroy");
(gdb) bt
#0  druid_shell::platform::x11::window::Window::destroy (self=0x555555746da0) at druid-shell/src/platform/x11/window.rs:513
#1  0x000055555558b8c6 in druid_shell::platform::x11::application::Application::quit (self=0x7fffffffc990)
    at druid-shell/src/platform/x11/application.rs:466
#2  0x000055555558081a in druid_shell::application::Application::quit (self=0x7fffffffc990)
    at druid-shell/src/application.rs:169
#3  0x000055555557a1cb in <invalidate::InvalidateTest as druid_shell::window::WinHandler>::destroy (self=0x555555739250)
    at druid-shell/examples/invalidate.rs:78
#4  0x00005555555d5da6 in druid_shell::platform::x11::window::Window::handle_destroy_notify
    (self=0x555555746da0, _destroy_notify=0x7fffffffda84) at druid-shell/src/platform/x11/window.rs:899
#5  0x0000555555588b01 in druid_shell::platform::x11::application::Application::handle_event
    (self=0x7fffffffe190, ev=0x7fffffffda80) at druid-shell/src/platform/x11/application.rs:326
#6  0x000055555558a29a in druid_shell::platform::x11::application::Application::run_inner (self=...)
    at druid-shell/src/platform/x11/application.rs:409
#7  0x000055555558b380 in druid_shell::platform::x11::application::Application::run (self=..., _handler=...)
    at druid-shell/src/platform/x11/application.rs:450
#8  0x00005555555806f8 in druid_shell::application::Application::run (self=..., handler=...)
    at druid-shell/src/application.rs:153
#9  0x000055555557a647 in invalidate::main () at druid-shell/examples/invalidate.rs:102
@luleyleo luleyleo added bug does not behave the way it is supposed to shell/x11 concerns the X11 backend labels Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug does not behave the way it is supposed to shell/x11 concerns the X11 backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants