@@ -20,10 +20,10 @@ import (
20
20
21
21
"github.com/wailsapp/wails/v3/internal/operatingsystem"
22
22
23
- "github.com/wailsapp/wails/v3/internal/signal"
24
-
25
23
"github.com/pkg/browser"
26
24
"github.com/samber/lo"
25
+ "github.com/wailsapp/wails/v3/internal/signal"
26
+
27
27
"github.com/wailsapp/wails/v3/internal/assetserver"
28
28
"github.com/wailsapp/wails/v3/internal/assetserver/webview"
29
29
"github.com/wailsapp/wails/v3/internal/capabilities"
@@ -101,7 +101,10 @@ func New(appOptions Options) *App {
101
101
case "/wails/runtime" :
102
102
messageProc .ServeHTTP (rw , req )
103
103
case "/wails/capabilities" :
104
- assetserver .ServeFile (rw , path , globalApplication .capabilities .AsBytes ())
104
+ err := assetserver .ServeFile (rw , path , globalApplication .capabilities .AsBytes ())
105
+ if err != nil {
106
+ result .handleFatalError (fmt .Errorf ("unable to serve capabilities: %s" , err .Error ()))
107
+ }
105
108
case "/wails/flags" :
106
109
updatedOptions := result .impl .GetFlags (appOptions )
107
110
flags , err := json .Marshal (updatedOptions )
@@ -581,73 +584,45 @@ func (a *App) Run() error {
581
584
a .impl = newPlatformApp (a )
582
585
go func () {
583
586
for {
584
- select {
585
- case <- a .ctx .Done ():
586
- return
587
- case event := <- applicationEvents :
588
- go a .handleApplicationEvent (event )
589
- }
587
+ event := <- applicationEvents
588
+ go a .handleApplicationEvent (event )
590
589
}
591
590
}()
592
591
go func () {
593
592
for {
594
- select {
595
- case <- a .ctx .Done ():
596
- return
597
- case event := <- windowEvents :
598
- go a .handleWindowEvent (event )
599
- }
593
+ event := <- windowEvents
594
+ go a .handleWindowEvent (event )
600
595
}
601
596
}()
602
597
go func () {
603
598
for {
604
- select {
605
- case <- a .ctx .Done ():
606
- return
607
- case request := <- webviewRequests :
608
- go a .handleWebViewRequest (request )
609
- }
599
+ request := <- webviewRequests
600
+ go a .handleWebViewRequest (request )
610
601
}
611
602
}()
612
603
go func () {
613
604
for {
614
- select {
615
- case <- a .ctx .Done ():
616
- return
617
- case event := <- windowMessageBuffer :
618
- go a .handleWindowMessage (event )
619
- }
605
+ event := <- windowMessageBuffer
606
+ go a .handleWindowMessage (event )
620
607
}
621
608
}()
622
609
go func () {
623
610
for {
624
- select {
625
- case <- a .ctx .Done ():
626
- return
627
- case event := <- windowKeyEvents :
628
- go a .handleWindowKeyEvent (event )
629
- }
611
+ event := <- windowKeyEvents
612
+ go a .handleWindowKeyEvent (event )
630
613
}
631
614
}()
632
615
go func () {
633
616
for {
634
- select {
635
- case <- a .ctx .Done ():
636
- return
637
- case dragAndDropMessage := <- windowDragAndDropBuffer :
638
- go a .handleDragAndDropMessage (dragAndDropMessage )
639
- }
617
+ dragAndDropMessage := <- windowDragAndDropBuffer
618
+ go a .handleDragAndDropMessage (dragAndDropMessage )
640
619
}
641
620
}()
621
+
642
622
go func () {
643
623
for {
644
- select {
645
- case <- a .ctx .Done ():
646
- return
647
- case menuItemID := <- menuItemClicked :
648
-
649
- go a .handleMenuItemClicked (menuItemID )
650
- }
624
+ menuItemID := <- menuItemClicked
625
+ go a .handleMenuItemClicked (menuItemID )
651
626
}
652
627
}()
653
628
@@ -717,31 +692,25 @@ func (a *App) handleApplicationEvent(event *ApplicationEvent) {
717
692
}
718
693
719
694
func (a * App ) handleDragAndDropMessage (event * dragAndDropMessage ) {
720
- if globalApplication .performingShutdown {
721
- return
722
- }
723
695
// Get window from window map
724
696
a .windowsLock .Lock ()
725
697
window , ok := a .windows [event .windowId ]
726
698
a .windowsLock .Unlock ()
727
699
if ! ok {
728
- log .Printf ("handleDragAndDropMessage: WebviewWindow #%d not found" , event .windowId )
700
+ log .Printf ("WebviewWindow #%d not found" , event .windowId )
729
701
return
730
702
}
731
703
// Get callback from window
732
704
window .HandleDragAndDropMessage (event .filenames )
733
705
}
734
706
735
707
func (a * App ) handleWindowMessage (event * windowMessage ) {
736
- if globalApplication .performingShutdown {
737
- return
738
- }
739
708
// Get window from window map
740
709
a .windowsLock .RLock ()
741
710
window , ok := a .windows [event .windowId ]
742
711
a .windowsLock .RUnlock ()
743
712
if ! ok {
744
- log .Printf ("handleWindowMessage: WebviewWindow #%d not found" , event .windowId )
713
+ log .Printf ("WebviewWindow #%d not found" , event .windowId )
745
714
return
746
715
}
747
716
// Check if the message starts with "wails:"
@@ -759,27 +728,18 @@ func (a *App) handleWebViewRequest(request *webViewAssetRequest) {
759
728
}
760
729
761
730
func (a * App ) handleWindowEvent (event * windowEvent ) {
762
- if globalApplication .performingShutdown {
763
- return
764
- }
765
731
// Get window from window map
766
732
a .windowsLock .RLock ()
767
733
window , ok := a .windows [event .WindowID ]
768
734
a .windowsLock .RUnlock ()
769
-
770
735
if ! ok {
771
- // Window not found - it's probably been destroyed
736
+ log . Printf ( " Window #%d not found" , event . WindowID )
772
737
return
773
738
}
774
-
775
- // Normal event handling for active windows
776
739
window .HandleWindowEvent (event .EventID )
777
740
}
778
741
779
742
func (a * App ) handleMenuItemClicked (menuItemID uint ) {
780
- if globalApplication .performingShutdown {
781
- return
782
- }
783
743
menuItem := getMenuItemByID (menuItemID )
784
744
if menuItem == nil {
785
745
log .Printf ("MenuItem #%d not found" , menuItemID )
0 commit comments