From 431a557e39fbbce3c0efa9e7a86c1807e80c3f16 Mon Sep 17 00:00:00 2001 From: "J.T. Sage" Date: Tue, 21 May 2024 14:42:58 -0400 Subject: [PATCH] possible fix for splash screen hang --- lib/modAssist_window_lib.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/modAssist_window_lib.js b/lib/modAssist_window_lib.js index ebff68f9..05e78436 100644 --- a/lib/modAssist_window_lib.js +++ b/lib/modAssist_window_lib.js @@ -831,27 +831,20 @@ module.exports.windowLib = class { * @param {function} openCallback */ createMainWindow (openCallback) { - this.win.main = this.createSubWindow('main', { noSelect : false, show : this.#debug, preload : 'mainWindow' }) + const doSplashScreen = true + + this.win.main = this.createSubWindow('main', { noSelect : false, show : !doSplashScreen, preload : 'mainWindow' }) this.win.main.on('closed', () => { this.win.main = null app.quit() }) - if ( !this.#debug ) { + if ( doSplashScreen ) { this.win.splash = this.createSubWindow('splash', { center : true, fixed : true, frame : false, move : false, useCustomTitle : false }) this.win.splash.loadURL(`file://${path.join(this.#path.render, 'splash.html')}?version=${app.getVersion()}`) this.win.splash.on('closed', () => { this.win.splash = null }) - - this.win.main.once('ready-to-show', () => { - setTimeout(() => { - this.win.main.show() - if ( this.isValid('splash') ) { - this.win.splash.destroy() - } - }, 2000) - }) } this.win.main.loadFile(path.join(this.#path.render, 'main.html')) @@ -870,6 +863,14 @@ module.exports.windowLib = class { }) this.win.main.webContents.on('did-finish-load', () => { + if ( doSplashScreen ) { + setTimeout(() => { + this.win.main.show() + this.safeClose('splash') + this.destroyAndFocus('splash') + }, 2000) + } + const currentFontSize = this.#settings.get('font_size') this.win.main.webContents.insertCSS(