Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 0026bb3b rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Clear all timers on exit (also in other places, to avoid errors when the...

Clear all timers on exit (also in other places, to avoid errors when the terminal is closed before the window) and factorize window creation
parent f5888e0a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!13Dev kubat: More work done on the instance
...@@ -22,6 +22,11 @@ var client; /* Sub process for the express server */ ...@@ -22,6 +22,11 @@ var client; /* Sub process for the express server */
var loopIntervals = []; var loopIntervals = [];
var loopTimeouts = []; var loopTimeouts = [];
function clearTimers() {
loopIntervals.forEach(timer => clearInterval(timer));
loopTimeouts.forEach(timer => clearTimeout(timer));
}
class Lektor { class Lektor {
constructor() { constructor() {
this.closed = true; this.closed = true;
...@@ -79,71 +84,70 @@ tail.on('line', function (data) { ...@@ -79,71 +84,70 @@ tail.on('line', function (data) {
* Creates the main window and process for the admin interface * * Creates the main window and process for the admin interface *
***************************************************************/ ***************************************************************/
function createInstanceWindow() { function defaultWindowOptions(title) {
/* Main window */ return {
win = new BrowserWindow({ title: title,
width: 1280, width: 720,
height: 720, height: 360,
minWidth: 1000,
minHeight: 360,
hasShadow: false, hasShadow: false,
frame: false, frame: true,
menuBarVisible: true, menuBarVisible: true,
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
worldSafeExecuteJavaScript: true, worldSafeExecuteJavaScript: true,
contextIsolation: false /* XXX: Otherwise 'require' is not defined in instance/index.html */, contextIsolation: true,
}, },
}); };
}
function createInstanceWindow() {
/* Main window */
const opt = defaultWindowOptions('Amadeus');
opt.width = 1280;
opt.height = 720;
opt.minWidth = 1000;
opt.minHeight = 360;
opt.menuBarVisible = false;
opt.frame = false;
opt.webPreferences.contextIsolation = false; /* XXX: Otherwise 'require' is not defined in instance/index.html */
win = new BrowserWindow(opt);
win.loadURL(`file://${__dirname}/instance/index.ejs`); win.loadURL(`file://${__dirname}/instance/index.ejs`);
win.once('ready-to-show', () => win.show());
}
function createLogWindow() {
/* Log window */
const opt = defaultWindowOptions('Amadeus - Log window');
opt.parent = win;
opt.webPreferences.contextIsolation = false; /* XXX: Otherwise 'require' is not defined in instance/index.html */
const logwindow = new BrowserWindow(opt);
logwindow.loadURL(`file://${__dirname}/instance/log.ejs`);
logwindow.once('ready-to-show', () => logwindow.show());
} }
function createUserViewWindow() { function createUserViewWindow() {
/* User view window */ /* User view window */
const uv = new BrowserWindow({ const opt = defaultWindowOptions('Amadeus - User view');
width: 720, const uv = new BrowserWindow(opt);
title: 'Kurisu',
height: 360,
frame: false,
parent: win,
webPreferences: {
nodeIntegration: true,
worldSafeExecuteJavaScript: true,
contextIsolation: true,
},
});
uv.loadURL(`http://localhost:${config.content.client.port}/`); uv.loadURL(`http://localhost:${config.content.client.port}/`);
uv.once('ready-to-show', () => { uv.once('ready-to-show', () => uv.show());
uv.show();
});
} }
function createKurisuWindow() { function createKurisuWindow() {
/* Kurisu window */ /* Kurisu window */
const kurisu = new BrowserWindow({ const opt = defaultWindowOptions('Amadeus - Kurisu');
width: 1280, const kurisu = new BrowserWindow(opt);
title: 'Kurisu',
height: 720,
frame: false,
parent: win,
webPreferences: {
nodeIntegration: true,
worldSafeExecuteJavaScript: true,
contextIsolation: true,
},
});
kurisu.loadURL(config.content.kurisu.url); kurisu.loadURL(config.content.kurisu.url);
kurisu.once('ready-to-show', () => { kurisu.once('ready-to-show', () => kurisu.show());
kurisu.show();
});
} }
/****************************** /******************************
* The end of the application * * The end of the application *
******************************/ ******************************/
ipcMain.on('close-app', (evt, arg) => { ipcMain.on('close-app', () => {
app.quit(); app.quit();
clearTimers();
}); });
app.on('quit', () => { app.on('quit', () => {
...@@ -291,8 +295,7 @@ ipcMain.on('verify-lektord', (event, arg) => { ...@@ -291,8 +295,7 @@ ipcMain.on('verify-lektord', (event, arg) => {
/* Install the clear function before registering all timers */ /* Install the clear function before registering all timers */
win.on('close', () => { win.on('close', () => {
logger.info('main', 'Close instance window, '); logger.info('main', 'Close instance window, ');
loopIntervals.forEach(timer => clearInterval(timer)); clearTimers();
loopTimeouts.forEach(timer => clearTimeout(timer));
}); });
lkt.reloadState(); lkt.reloadState();
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter