TagSpaces is an offline, open source, document manager with tagging support
Handling errors and show a dialog to reload, update TrayIcon menu
kristiyanddccd54fdaf16c
diff --git a/data/electron/main.js b/data/electron/main.jsindex b2e63911f..80b3ca33c 100644--- a/data/electron/main.js+++ b/data/electron/main.js@@ -41,7 +41,6 @@ ipcMain.on('synchronous-message', function(event, arg) {});ipcMain.on('quit-application', function(event, arg) {- //console.log(arg);app.quit();});@@ -59,18 +58,6 @@ app.on('window-all-closed', function() {//}});-//app.setUserTasks([-// {-// program: process.execPath,-// arguments: '--new-window',-// iconPath: process.execPath,-// iconIndex: 0,-// title: 'New Window',-// description: 'Create a new window'-// }-//]);-//-app.on('ready', function(event) {console.log(app.getLocale());@@ -91,26 +78,6 @@ app.on('ready', function(event) {mainWindow.webContents.openDevTools();}- process.on('uncaughtException', function(error) {- // Handle the error- if (error) {- const options = {- type: 'info',- title: 'Renderer Process Crashed',- message: 'This process has crashed.',- buttons: ['Reload', 'Close']- };- dialog.showMessageBox(options, function(index) {- if (index === 0) {- mainWindow.reload();- } else {- mainWindow.close();- }- });- mainWindow.hide();- }- });-var webContents = mainWindow.webContents;webContents.on('crash', function(e) {@@ -125,6 +92,23 @@ app.on('ready', function(event) {mainWindow = null;});+ mainWindow.webContents.on('crashed', function(){+ const options = {+ type: 'info',+ title: 'Renderer Process Crashed',+ message: 'This process has crashed.',+ buttons: ['Reload', 'Close']+ };+ dialog.showMessageBox(options, function(index) {+ mainWindow.hide();+ if (index === 0) {+ mainWindow.reload();+ } else {+ mainWindow.close();+ }+ });+ });+//mainWindow.on('minimize', function(event) {// event.preventDefault();// mainWindow.hide();@@ -144,13 +128,44 @@ app.on('ready', function(event) {mainWindow.show();}},+ {+ label: 'New File',+ click: function() {+ mainWindow.show();+ mainWindow.webContents.send("new-file", "new");+ }+ },+ {+ label: 'Next File',+ click: function() {+ mainWindow.show();+ mainWindow.webContents.send("next-file", "next");+ }+ },+ {+ label: 'Previous File',+ click: function() {+ mainWindow.show();+ mainWindow.webContents.send("previous-file", "previous");+ }+ },+ //{+ // label: 'Stop Playback',+ // click: function() {+ // mainWindow.show();+ // }+ //},+ //{+ // label: 'Resume Playback',+ // click: function() {+ // mainWindow.show();+ // }+ //},{label: 'Quit',click: function(event) {- console.log(event);app.quit();//event.ipcRenderer.send('remove-tray');- //ipcRenderer.send('window-all-closed');}}];@@ -186,7 +201,29 @@ app.on('ready', function(event) {mainWindow.webContents.send("previous-file", "previous");});- globalShortcut.register('CommandOrControl+Alt+K', function() {+ globalShortcut.register('CommandOrControl+Alt+L', function() {mainWindow.webContents.send("showing-tagspaces", "tagspaces");});});++process.on('uncaughtException', function(error) {+ if (error.stack) {+ console.error('error:', error.stack);+ }+ // Handle the error+ if (error) {+ const options = {+ type: 'info',+ title: 'Renderer Process Crashed',+ message: 'This process has crashed.',+ buttons: ['Reload', 'Close']+ };+ dialog.showMessageBox(mainWindow, options, function(index) {+ if (index === 0) {+ mainWindow.reload();+ } else {+ mainWindow.close();+ }+ });+ }+});\ No newline at end of file