@@ -65,12 +65,14 @@ func setUI(doc document.Document) {
6565
6666 buttonBar := container .New (layout .NewHBoxLayout (), buttonBarObjects ... )
6767
68- state .documentUiMainContainer .RemoveAll ()
69- state .documentUiMainContainer .Add (page )
70- state .documentUiMainContainer .Add (buttonBar )
68+ fyne .DoAndWait (func () {
69+ state .documentUiMainContainer .RemoveAll ()
70+ state .documentUiMainContainer .Add (page )
71+ state .documentUiMainContainer .Add (buttonBar )
7172
72- state .startPage .Hide ()
73- state .documentUiMainContainer .Show ()
73+ state .startPage .Hide ()
74+ state .documentUiMainContainer .Show ()
75+ })
7476
7577 resizeWindow (false )
7678}
@@ -117,8 +119,10 @@ func setStatus(statusId string, err error) {
117119 }
118120
119121 status := t (statusId )
120- state .statusBar .SetStatus (status , isError )
121- state .statusBar .Refresh ()
122+ fyne .Do (func () {
123+ state .statusBar .SetStatus (status , isError )
124+ state .statusBar .Refresh ()
125+ })
122126}
123127
124128func updateMedicalDocHandler (doc * document.MedicalDocument ) func () {
@@ -159,8 +163,10 @@ func setTimedStatus(label string) {
159163 go func () {
160164 time .Sleep (2 * time .Second )
161165 if state .statusBar .GetStatus () == label {
162- state .statusBar .SetStatus ("" , false )
163- state .statusBar .Refresh ()
166+ fyne .Do (func () {
167+ state .statusBar .SetStatus ("" , false )
168+ state .statusBar .Refresh ()
169+ })
164170 }
165171 }()
166172}
@@ -179,15 +185,19 @@ func setTimedStatusError(labelKey string, err error) {
179185 go func () {
180186 time .Sleep (2 * time .Second )
181187 if state .statusBar .GetStatus () == label {
182- state .statusBar .SetStatus ("" , false )
183- state .statusBar .Refresh ()
188+ fyne .Do (func () {
189+ state .statusBar .SetStatus ("" , false )
190+ state .statusBar .Refresh ()
191+ })
184192 }
185193 }()
186194}
187195
188196func showDocumentUI () {
189- state .mainContainer .RemoveAll ()
190- state .mainContainer .Add (state .documentUi )
197+ fyne .DoAndWait (func () {
198+ state .mainContainer .RemoveAll ()
199+ state .mainContainer .Add (state .documentUi )
200+ })
191201}
192202
193203func resizeWindow (keepCurrentSize bool ) {
@@ -205,5 +215,7 @@ func resizeWindow(keepCurrentSize bool) {
205215 }
206216 }
207217
208- state .window .Resize (minSize )
218+ fyne .Do (func () {
219+ state .window .Resize (minSize )
220+ })
209221}
0 commit comments