mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app: delete workarounds for driver callback deadlocks
Driver methods are invoked during event processing, but some of them may generate events that would in turn deadlock because event processing is not re-entrant. However, a previous change moved all such calls outside event processing and so chained events can no longer deadlock. This change deletes the workarounds. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+2
-2
@@ -427,7 +427,7 @@ func Java_org_gioui_GioView_onBack(env *C.JNIEnv, class C.jclass, view C.jlong)
|
||||
//export Java_org_gioui_GioView_onFocusChange
|
||||
func Java_org_gioui_GioView_onFocusChange(env *C.JNIEnv, class C.jclass, view C.jlong, focus C.jboolean) {
|
||||
w := views[view]
|
||||
go w.callbacks.Event(key.FocusEvent{Focus: focus == C.JNI_TRUE})
|
||||
w.callbacks.Event(key.FocusEvent{Focus: focus == C.JNI_TRUE})
|
||||
}
|
||||
|
||||
//export Java_org_gioui_GioView_onWindowInsets
|
||||
@@ -783,7 +783,7 @@ func (w *window) ReadClipboard() {
|
||||
return
|
||||
}
|
||||
content := goString(env, C.jstring(c))
|
||||
go w.callbacks.Event(clipboard.Event{Text: content})
|
||||
w.callbacks.Event(clipboard.Event{Text: content})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -256,7 +256,7 @@ func onTouch(last C.int, view, touchRef C.CFTypeRef, phase C.NSInteger, x, y C.C
|
||||
|
||||
func (w *window) ReadClipboard() {
|
||||
content := nsstringToString(C.readClipboard())
|
||||
go w.w.Event(clipboard.Event{Text: content})
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
}
|
||||
|
||||
func (w *window) WriteClipboard(s string) {
|
||||
|
||||
+2
-8
@@ -198,7 +198,7 @@ func (w *window) contextView() C.CFTypeRef {
|
||||
|
||||
func (w *window) ReadClipboard() {
|
||||
content := nsstringToString(C.readClipboard())
|
||||
go w.w.Event(clipboard.Event{Text: content})
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
}
|
||||
|
||||
func (w *window) WriteClipboard(s string) {
|
||||
@@ -283,13 +283,7 @@ func (w *window) runOnMain(f func()) {
|
||||
}
|
||||
|
||||
func (w *window) Close() {
|
||||
// close immediately calls gio_onClose which sends events
|
||||
// causing a deadlock because Close is called during an event.
|
||||
// Break the deadlock by deferring the close, making Close more
|
||||
// akin to a message like the other platforms.
|
||||
go w.runOnMain(func() {
|
||||
C.closeWindow(w.window)
|
||||
})
|
||||
C.closeWindow(w.window)
|
||||
}
|
||||
|
||||
func (w *window) setStage(stage system.Stage) {
|
||||
|
||||
+1
-3
@@ -511,9 +511,7 @@ func (w *window) readClipboard() error {
|
||||
}
|
||||
defer windows.GlobalUnlock(mem)
|
||||
content := gowindows.UTF16PtrToString((*uint16)(unsafe.Pointer(ptr)))
|
||||
go func() {
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
}()
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -261,7 +261,7 @@ func (w *Window) Invalidate() {
|
||||
|
||||
// Option applies the options to the window.
|
||||
func (w *Window) Option(opts ...Option) {
|
||||
go w.driverDefer(func(d driver) {
|
||||
w.driverDefer(func(d driver) {
|
||||
c := new(config)
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
@@ -274,21 +274,21 @@ func (w *Window) Option(opts ...Option) {
|
||||
// of a clipboard.Event. Multiple reads may be coalesced
|
||||
// to a single event.
|
||||
func (w *Window) ReadClipboard() {
|
||||
go w.driverDefer(func(d driver) {
|
||||
w.driverDefer(func(d driver) {
|
||||
d.ReadClipboard()
|
||||
})
|
||||
}
|
||||
|
||||
// WriteClipboard writes a string to the clipboard.
|
||||
func (w *Window) WriteClipboard(s string) {
|
||||
go w.driverDefer(func(d driver) {
|
||||
w.driverDefer(func(d driver) {
|
||||
d.WriteClipboard(s)
|
||||
})
|
||||
}
|
||||
|
||||
// SetCursorName changes the current window cursor to name.
|
||||
func (w *Window) SetCursorName(name pointer.CursorName) {
|
||||
go w.driverDefer(func(d driver) {
|
||||
w.driverDefer(func(d driver) {
|
||||
d.SetCursor(name)
|
||||
})
|
||||
}
|
||||
@@ -299,7 +299,7 @@ func (w *Window) SetCursorName(name pointer.CursorName) {
|
||||
// Currently, only macOS, Windows and X11 drivers implement this functionality,
|
||||
// all others are stubbed.
|
||||
func (w *Window) Close() {
|
||||
go w.driverDefer(func(d driver) {
|
||||
w.driverDefer(func(d driver) {
|
||||
d.Close()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user