forked from Leak_Technologies/VideoTools
Parse drag data manually to avoid GetURIs crashes
This commit is contained in:
parent
20c4b5d177
commit
29bc1ac19c
|
|
@ -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
|
||||
}
|
||||
// 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
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user