File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -173,8 +173,16 @@ - (void)popUpContextMenu:(electron::AtomMenuModel*)menu_model {
173
173
useDefaultAccelerator: NO ]);
174
174
// Hacky way to mimic design of ordinary tray menu.
175
175
[statusItem_ setMenu: [menuController menu ]];
176
+ // -performClick: is a blocking call, which will run the task loop inside
177
+ // itself. This can potentially include running JS, which can result in
178
+ // this object being released. We take a temporary reference here to make
179
+ // sure we stay alive long enough to successfully return from this
180
+ // function.
181
+ // TODO(nornagon/codebytere): Avoid nesting task loops here.
182
+ [self retain ];
176
183
[[statusItem_ button ] performClick: self ];
177
184
[statusItem_ setMenu: [menuController_ menu ]];
185
+ [self release ];
178
186
return ;
179
187
}
180
188
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ describe('tray module', () => {
51
51
} )
52
52
tray . popUpContextMenu ( )
53
53
} )
54
+
55
+ it ( 'can be called with a menu' , ( ) => {
56
+ const menu = Menu . buildFromTemplate ( [ { label : 'Test' } ] )
57
+ expect ( ( ) => {
58
+ tray . popUpContextMenu ( menu )
59
+ } ) . to . not . throw ( )
60
+ } )
54
61
} )
55
62
56
63
describe ( 'tray.getBounds()' , ( ) => {
You can’t perform that action at this time.
0 commit comments