Only call setJumpList() after first window is opening (fixes #21963)

This commit is contained in:
Benjamin Pasero
2017-03-06 08:25:29 +01:00
parent e0163462b5
commit c8af1d0c55

View File

@@ -141,6 +141,8 @@ export class WindowsManager implements IWindowsMainService {
private windowsState: IWindowsState;
private lastClosedWindowState: IWindowState;
private firstWindowLoading: boolean;
private _onRecentPathsChange = new Emitter<void>();
onRecentPathsChange: CommonEvent<void> = this._onRecentPathsChange.event;
@@ -171,8 +173,6 @@ export class WindowsManager implements IWindowsMainService {
this.initialUserEnv = initialUserEnv;
this.windowsState = this.storageService.getItem<IWindowsState>(WindowsManager.windowsStateStorageKey) || { openedFolders: [] };
this.updateWindowsJumpList();
}
private registerListeners(): void {
@@ -862,6 +862,7 @@ export class WindowsManager implements IWindowsMainService {
vscodeWindow.win.webContents.removeAllListeners('devtools-reload-page'); // remove built in listener so we can handle this on our own
vscodeWindow.win.webContents.on('devtools-reload-page', () => this.reload(vscodeWindow));
vscodeWindow.win.webContents.on('crashed', () => this.onWindowError(vscodeWindow, WindowError.CRASHED));
vscodeWindow.win.webContents.on('did-start-loading', () => this.onWindowStartLoading(vscodeWindow));
vscodeWindow.win.on('unresponsive', () => this.onWindowError(vscodeWindow, WindowError.UNRESPONSIVE));
vscodeWindow.win.on('closed', () => this.onWindowClosed(vscodeWindow));
@@ -1264,11 +1265,26 @@ export class WindowsManager implements IWindowsMainService {
return pathA === pathB;
}
private onWindowStartLoading(win: VSCodeWindow): void {
if (!this.firstWindowLoading) {
this.firstWindowLoading = true;
// Apply jump list when our first window is loading. We do this because
// setJumpList() seems to take quite a bit of time and would block window
// loading ( = startup performance) significantly otherwise
setTimeout(() => this.updateWindowsJumpList()); // unwind from onWindowStartLoading event
}
}
private updateWindowsJumpList(): void {
if (!platform.isWindows) {
return; // only on windows
}
if (!this.firstWindowLoading) {
return; // push this out until a window starts loading for perf reasons
}
const jumpList: Electron.JumpListCategory[] = [];
// Tasks