internal/ui: bug fix: crash by dropping an HTML element onto the canvas (#3044)

Closes #3043
This commit is contained in:
cowboy.macke 2024-07-18 10:19:21 +02:00 committed by GitHub
parent 839cb9a724
commit 3a6aaac5ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -705,14 +705,17 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
func (u *UserInterface) appendDroppedFiles(data js.Value) {
u.dropFileM.Lock()
defer u.dropFileM.Unlock()
items := data.Get("items")
if items.Length() <= 0 {
for i := 0; i < items.Length(); i++ {
kind := items.Index(i).Get("kind").String()
switch kind {
case "file":
fs := items.Index(i).Call("webkitGetAsEntry").Get("filesystem").Get("root")
u.inputState.DroppedFiles = file.NewFileEntryFS(fs)
return
}
fs := items.Index(0).Call("webkitGetAsEntry").Get("filesystem").Get("root")
u.inputState.DroppedFiles = file.NewFileEntryFS(fs)
}
}
func (u *UserInterface) forceUpdateOnMinimumFPSMode() {