mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 08:25:34 +00:00
app: [X11] don't send events after DestroyEvent
Before this change, a FrameEvent may be delivered after DestroyEvent, leading to a panic. Destroy the X11 window immediately thus ensuring no events can be delivered after destroy. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+7
-4
@@ -389,6 +389,7 @@ func (w *x11Window) ProcessEvent(e event.Event) {
|
|||||||
func (w *x11Window) shutdown(err error) {
|
func (w *x11Window) shutdown(err error) {
|
||||||
w.ProcessEvent(X11ViewEvent{})
|
w.ProcessEvent(X11ViewEvent{})
|
||||||
w.ProcessEvent(DestroyEvent{Err: err})
|
w.ProcessEvent(DestroyEvent{Err: err})
|
||||||
|
w.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *x11Window) Event() event.Event {
|
func (w *x11Window) Event() event.Event {
|
||||||
@@ -398,9 +399,6 @@ func (w *x11Window) Event() event.Event {
|
|||||||
w.dispatch()
|
w.dispatch()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, destroy := evt.(DestroyEvent); destroy {
|
|
||||||
w.destroy()
|
|
||||||
}
|
|
||||||
return evt
|
return evt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,7 +462,12 @@ func (w *x11Window) dispatch() {
|
|||||||
// Check for pending draw events before checking animation or blocking.
|
// Check for pending draw events before checking animation or blocking.
|
||||||
// This fixes an issue on Xephyr where on startup XPending() > 0 but
|
// This fixes an issue on Xephyr where on startup XPending() > 0 but
|
||||||
// poll will still block. This also prevents no-op calls to poll.
|
// poll will still block. This also prevents no-op calls to poll.
|
||||||
if syn = w.handler.handleEvents(); !syn {
|
syn = w.handler.handleEvents()
|
||||||
|
if w.x == nil {
|
||||||
|
// handleEvents received a close request and destroyed the window.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !syn {
|
||||||
anim = w.animating
|
anim = w.animating
|
||||||
if !anim {
|
if !anim {
|
||||||
// Clear poll events.
|
// Clear poll events.
|
||||||
|
|||||||
Reference in New Issue
Block a user