Skip to content

Commit d279742

Browse files
committed
fix(WindowState): crash if not window state file
1 parent cf70140 commit d279742

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ powerSaveBlocker.start('prevent-app-suspension');
3232
process.on('unhandledRejection', (reason, p) => {
3333
Logger.e(`Unhandled Rejection at: ${p}`);
3434
Logger.e(`reason: ${reason}`);
35+
console.error(reason)
3536
});
3637

3738
let mainWindowPromiseResolver;
@@ -85,8 +86,8 @@ electron.app.whenReady().then(function() {
8586
nodeIntegration: true
8687
},
8788
// start with state from windowStateKeeper
88-
x: mainWindowState.x,
89-
y: mainWindowState.y,
89+
x: mainWindowState.x || 0,
90+
y: mainWindowState.y || 0,
9091
width: mainWindowState.width,
9192
height: mainWindowState.height,
9293
};
@@ -99,7 +100,7 @@ electron.app.whenReady().then(function() {
99100
// e.g. メインディスプレイより大きなサイズや、サブディスプレイに表示している場合など
100101
// なので、作成したあとに再度サイズを設定し直す
101102
// 多分electronの不具合
102-
mainWindow.setPosition(mainWindowState.x, mainWindowState.y, false);
103+
mainWindow.setPosition(mainWindowState.x || 0, mainWindowState.y || 0, false);
103104
mainWindow.setSize(mainWindowState.width, mainWindowState.height)
104105

105106
mainWindowState.manage(mainWindow);

0 commit comments

Comments
 (0)