From 29bc1ac19c8471fa9f7bc62cf3cc2ddf4d56aa4b Mon Sep 17 00:00:00 2001 From: Stu Date: Sat, 13 Dec 2025 22:46:46 -0500 Subject: [PATCH] Parse drag data manually to avoid GetURIs crashes --- cmd/gtkplayer/main.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/cmd/gtkplayer/main.go b/cmd/gtkplayer/main.go index 95e9dd0..c5ff519 100644 --- a/cmd/gtkplayer/main.go +++ b/cmd/gtkplayer/main.go @@ -5,6 +5,7 @@ import ( "log" "path/filepath" "time" + "strings" "git.leaktechnologies.dev/stu/VT_Player/player/mpvembed" @@ -288,19 +289,28 @@ func setupDragDest(p *pane, win *gtk.Window) { if data == nil { return } - var path string - if uris := data.GetURIs(); len(uris) > 0 { - path = uriToPath(uris[0]) - } - if path == "" { + raw := data.GetData() + if len(raw) == 0 { + // try text fallback if txt := data.GetText(); txt != "" { - path = uriToPath(txt) + raw = []byte(txt) } } - if path == "" { + if len(raw) == 0 { return } - loadIntoPane(p, path) + // text/uri-list: newline or CRLF separated + lines := strings.Split(string(raw), "\n") + for _, ln := range lines { + ln = strings.TrimSpace(ln) + if ln == "" { + continue + } + if path := uriToPath(ln); path != "" { + loadIntoPane(p, path) + break + } + } }) }