Skip to content

Commit

Permalink
Remove old clipboard workarounds after changes in GLFW
Browse files Browse the repository at this point in the history
See fyne-io#1136. The clipboard no longer crashes when pasting empy content (also verified locally). The clipboard also no longer require access to the window struct. Clean up the code. As the clipboard no longer needs the viewport, we can also remove a possible crash when getting a clipboard from a window that has yet to be set up.
  • Loading branch information
Jacalz committed Nov 23, 2023
1 parent 802f92b commit 0ab2a60
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
10 changes: 1 addition & 9 deletions internal/driver/glfw/clipboard.go
Expand Up @@ -16,9 +16,7 @@ import (
var _ fyne.Clipboard = (*clipboard)(nil)

// clipboard represents the system clipboard
type clipboard struct {
window *glfw.Window
}
type clipboard struct{}

// Content returns the clipboard content
func (c *clipboard) Content() string {
Expand Down Expand Up @@ -64,12 +62,6 @@ func (c *clipboard) SetContent(content string) {

func (c *clipboard) setContent(content string) {
runOnMain(func() {
defer func() {
if r := recover(); r != nil {
fyne.LogError("GLFW clipboard error (details above)", nil)
}
}()

glfw.SetClipboardString(content)
})
}
9 changes: 1 addition & 8 deletions internal/driver/glfw/window.go
Expand Up @@ -229,14 +229,7 @@ func (w *window) ShowAndRun() {

// Clipboard returns the system clipboard
func (w *window) Clipboard() fyne.Clipboard {
if w.view() == nil {
return nil
}

if w.clipboard == nil {
w.clipboard = &clipboard{window: w.viewport}
}
return w.clipboard
return &clipboard{}
}

func (w *window) Content() fyne.CanvasObject {
Expand Down
2 changes: 0 additions & 2 deletions internal/driver/glfw/window_desktop.go
Expand Up @@ -77,8 +77,6 @@ type window struct {
icon fyne.Resource
mainmenu *fyne.MainMenu

clipboard fyne.Clipboard

master bool
fullScreen bool
centered bool
Expand Down

0 comments on commit 0ab2a60

Please sign in to comment.