Skip to content

Commit

Permalink
fixes #85392
Browse files Browse the repository at this point in the history
  • Loading branch information
sbatten committed Dec 13, 2019
1 parent b601d96 commit 4a939f1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/vs/platform/menubar/electron-main/menubarMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,34 @@ import { IMenubarService, IMenubarData } from 'vs/platform/menubar/node/menubar'
import { Menubar } from 'vs/platform/menubar/electron-main/menubar';
import { ILogService } from 'vs/platform/log/common/log';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';

export class MenubarMainService implements IMenubarService {

_serviceBrand: undefined;

private _menubar: Menubar;
private _menubar: Menubar | undefined;

constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@ILogService private readonly logService: ILogService
) {
// Install Menu
this._menubar = this.instantiationService.createInstance(Menubar);
this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen).then(() => {
this._menubar = this.instantiationService.createInstance(Menubar);
});
}

updateMenubar(windowId: number, menus: IMenubarData): Promise<void> {
this.logService.trace('menubarService#updateMenubar', windowId);
return this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen).then(() => {
this.logService.trace('menubarService#updateMenubar', windowId);

if (this._menubar) {
this._menubar.updateMenu(menus, windowId);
}
if (this._menubar) {
this._menubar.updateMenu(menus, windowId);
}

return Promise.resolve(undefined);
return undefined;
});
}
}

0 comments on commit 4a939f1

Please sign in to comment.