55
66import { assign } from 'vs/base/common/objects' ;
77import { memoize } from 'vs/base/common/decorators' ;
8- import { IDisposable , toDisposable , dispose } from 'vs/base/common/lifecycle' ;
98import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
109import { TPromise } from 'vs/base/common/winjs.base' ;
1110import { IProcessEnvironment } from 'vs/base/common/platform' ;
@@ -20,7 +19,6 @@ export class SharedProcess implements ISharedProcess {
2019 private barrier = new Barrier ( ) ;
2120
2221 private window : Electron . BrowserWindow ;
23- private disposables : IDisposable [ ] = [ ] ;
2422
2523 constructor (
2624 private readonly environmentService : IEnvironmentService ,
@@ -29,20 +27,6 @@ export class SharedProcess implements ISharedProcess {
2927 private readonly machineId : string ,
3028 private readonly userEnv : IProcessEnvironment ,
3129 ) {
32- this . registerListeners ( ) ;
33- }
34-
35- private registerListeners ( ) : void {
36-
37- // Shut the shared process down when we are quitting
38- //
39- // Note: because we veto the window close, we must call our dispose() method,
40- // which removes the veto. Otherwise the application would never quit because
41- // the shared process window is refusing to close!
42- //
43- this . lifecycleService . onShutdown ( ( ) => {
44- this . dispose ( ) ;
45- } ) ;
4630 }
4731
4832 @memoize
@@ -79,9 +63,15 @@ export class SharedProcess implements ISharedProcess {
7963 } ;
8064
8165 this . window . on ( 'close' , onClose ) ;
82- this . disposables . push ( toDisposable ( ( ) => this . window . removeListener ( 'close' , onClose ) ) ) ;
8366
84- this . disposables . push ( toDisposable ( ( ) => {
67+ this . lifecycleService . onShutdown ( ( ) => {
68+ // Shut the shared process down when we are quitting
69+ //
70+ // Note: because we veto the window close, we must first remove our veto.
71+ // Otherwise the application would never quit because the shared process
72+ // window is refusing to close!
73+ //
74+ this . window . removeListener ( 'close' , onClose ) ;
8575
8676 // Electron seems to crash on Windows without this setTimeout :|
8777 setTimeout ( ( ) => {
@@ -93,7 +83,7 @@ export class SharedProcess implements ISharedProcess {
9383
9484 this . window = null ;
9585 } , 0 ) ;
96- } ) ) ;
86+ } ) ;
9787
9888 return new TPromise < void > ( ( c , e ) => {
9989 ipcMain . once ( 'handshake:hello' , ( { sender } : { sender : any } ) => {
@@ -133,8 +123,4 @@ export class SharedProcess implements ISharedProcess {
133123 this . window . webContents . closeDevTools ( ) ;
134124 this . window . hide ( ) ;
135125 }
136-
137- dispose ( ) : void {
138- this . disposables = dispose ( this . disposables ) ;
139- }
140126}
0 commit comments