Electron remote module causes application crash

0

I'm having trouble using the electron. Whenever I try to use the remote module outside the main.js application of a reload alone. I do not have any reload code in my script. Whenever I use showOpenDialog the application will restart. I have a button that when clicked should open the showOpenDialog and assign the value to an input, however when the selection window is opened the application restarts and when the user clicks to select the file the function is no longer running. I made a debug through the Developer Tools so I realized the electron runs the function to some extent, then it ignores the rest of the function and a reload generating that message on the console.

Has anyone ever had anything like this?

Javascript

function carregarPastaArquivosYML(){
    try{

        const options = {
            properties: ['openDirectory', '']
        };

        dialog.showOpenDialog(options, (path) => {
            
            $('#CaminhoArquivosMensageria').val(path);
        });

    } catch(error) {
        /*
        $("#modalErro").modal("open");
        $(".conteudo-erro").html('').html("Error Code: " + error.code + " | Error Message: " + error.message);
        */
        alert(error);
    }
    
}

This is my main.js

            const electron = require('electron');
            const { BrowserWindow, dialog, Menu, remote, app } = electron;
            const url = require('url');
            const path = require('path');

            let TelaApplication;
            let TelaApplicationWatchdog;

            let TelaInicial;

            //Definindo ambiente de Produção ou de Desenvolvimento.
            // production = Produção
            //development = Desenvolvimento
            process.env.NODE_ENV = 'development';



            app.on('ready', () => {


                let screenSize = electron.screen.getPrimaryDisplay().size;
                TelaInicial = new BrowserWindow({
                    height: screenSize.height,
                    width: screenSize.width,
                    minHeight: 600,
                    minWidth: 800
                });


                TelaInicial.loadURL(url.format({
                    pathname: path.join(__dirname, './pages/config_application_yml.html'),
                    protocol: 'file:'
                }));

            });


            let menuTemplate = [
                {
                    label: 'Configurar Mensageria',
                    submenu: [
                        {
                            label: 'Configurar Application.yml',
                            click: () => {
                                TelaInicial.loadURL(url.format({
                                    pathname: path.join(__dirname, './pages/config_application_yml.html'),
                                    protocol: 'file:'
                                }));
                            }
                        }, {
                            label: 'Configurar Application-watchdog.yml',
                            click: () => {
                                TelaInicial.loadURL(url.format({
                                    pathname: path.join(__dirname, './pages/config_application_watchdog_yml.html'),
                                    protocol: 'file:'
                                }));
                            }
                        }
                    ]
                }, {
                    label: "Opções",
                    submenu: [
                        {
                            label: "Recarregar Arquivo",
                            click: () => {
                                BrowserWindow.getFocusedWindow().reload();
                            }
                        }
                    ]
                }, {
                    label: "Configurações",
                    submenu: [
                        {
                            label: "Configurar Pasta Mensageria",
                            click: () => {
                                TelaInicial.loadURL(url.format({
                                    pathname: path.join(__dirname, './pages/configurador-aplicacao.html'),
                                    protocol: 'file:'
                                }));
                            }
                        }
                    ]
                }
            ]


            //Adicionar Developer Tools se não for ambiente de Produção
            if(process.env.NODE_ENV !== 'production'){
                menuTemplate.push({
                    label: 'Developer Tools',
                    submenu: [
                        {
                            label: 'Toggle DevTools',
                            accelerator: process.platform == 'darwin' ? 'Command+Q' : 'Ctrl+Q' ,
                            click(item, focusedWindow){
                                focusedWindow.toggleDevTools();
                            }
                        }, {
                            role: 'reload'
                        }
                    ]
                })
            }

            const menu = Menu.buildFromTemplate(menuTemplate);
            Menu.setApplicationMenu(menu);

I found this thread in git but it seems that the problem has not been solved It seems to be a bug of the own electron. link

    
asked by anonymous 25.04.2018 / 16:48

0 answers