File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,14 @@ func Register(onReady func(), onExit func()) {
127
127
128
128
// ResetMenu will remove all menu items
129
129
func ResetMenu () {
130
+ menuItemsLock .Lock ()
131
+ id := currentID .Load ()
132
+ menuItemsLock .Unlock ()
133
+ for i , item := range menuItems {
134
+ if i < id {
135
+ item .Remove ()
136
+ }
137
+ }
130
138
resetMenu ()
131
139
}
132
140
@@ -224,6 +232,11 @@ func (item *MenuItem) Remove() {
224
232
removeMenuItem (item )
225
233
menuItemsLock .Lock ()
226
234
delete (menuItems , item .id )
235
+ select {
236
+ case <- item .ClickedCh :
237
+ default :
238
+ }
239
+ close (item .ClickedCh )
227
240
menuItemsLock .Unlock ()
228
241
}
229
242
@@ -252,6 +265,13 @@ func (item *MenuItem) Uncheck() {
252
265
// update propagates changes on a menu item to systray
253
266
func (item * MenuItem ) update () {
254
267
menuItemsLock .Lock ()
268
+ if v , ok := menuItems [item .id ]; ok {
269
+ select {
270
+ case <- v .ClickedCh :
271
+ default :
272
+ }
273
+ close (v .ClickedCh )
274
+ }
255
275
menuItems [item .id ] = item
256
276
menuItemsLock .Unlock ()
257
277
addOrUpdateMenuItem (item )
You can’t perform that action at this time.
0 commit comments