forked from joejulian/gio
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) {
|
||||
w.ProcessEvent(X11ViewEvent{})
|
||||
w.ProcessEvent(DestroyEvent{Err: err})
|
||||
w.destroy()
|
||||
}
|
||||
|
||||
func (w *x11Window) Event() event.Event {
|
||||
@@ -398,9 +399,6 @@ func (w *x11Window) Event() event.Event {
|
||||
w.dispatch()
|
||||
continue
|
||||
}
|
||||
if _, destroy := evt.(DestroyEvent); destroy {
|
||||
w.destroy()
|
||||
}
|
||||
return evt
|
||||
}
|
||||
}
|
||||
@@ -464,7 +462,12 @@ func (w *x11Window) dispatch() {
|
||||
// Check for pending draw events before checking animation or blocking.
|
||||
// This fixes an issue on Xephyr where on startup XPending() > 0 but
|
||||
// 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
|
||||
if !anim {
|
||||
// Clear poll events.
|
||||
|
||||
Reference in New Issue
Block a user