Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Object has been destroyed #23

Open
ravisojitra opened this issue Jan 19, 2018 · 1 comment
Open

Error: Object has been destroyed #23

ravisojitra opened this issue Jan 19, 2018 · 1 comment

Comments

@ravisojitra
Copy link

ravisojitra commented Jan 19, 2018

Error & Stack Trace
Error: Object has been destroyed
at D:\ionic\demos\electron\HK-hardika\myapp-source\node_modules\electron-notify\index.js:309:23
at AnimationQueue.animate (D:\ionic\demos\electron\HK-hardika\myapp-source\node_modules\electron-notify\index.js:28:15)
at D:\ionic\demos\electron\HK-hardika\myapp-source\node_modules\electron-notify\index.js:32:20
at

Code:

function A(){
     eNotify.closeAll();
  eNotify.setConfig({
    animateInParallel: true,
    appIcon : path.join(__dirname, "./logo.ico")
  });

  eNotify.notify({ 
    title: 'Your offline data are being synced to online', 
    text: 'Please wait a while' 
  });
  setTimeout(function(){
    otherFunction();
  },3000)
}

otherFunction(){
   eNotify.closeAll();
  
  eNotify.setConfig({
    animateInParallel: true,
    appIcon : path.join(__dirname, "./logo.ico"),
    displayTime: 5000 
  });

  eNotify.notify({ 
    title: 'Your offline data are synced successfully', 
    text: 'Please wait while we redirect you'
  });
}
@mashahbazi
Copy link

I have same issue and my solution for this is changing some part of codes. this happen when you destroy the electron window but notification want too use it so I go to index.js and change method getWindow() like this:

function getWindow() {
    return new Promise(function (resolve) {
        let notificationWindow
        // Are there still inactiveWindows?
        if (inactiveWindows.length > 0) {
            notificationWindow = inactiveWindows.pop()
            try {
                notificationWindow.setPosition(0,0,false)
                resolve(notificationWindow)
            }catch (e) {
                let windowProperties = config.defaultWindow
                windowProperties.width = config.width
                windowProperties.height = config.height
                notificationWindow = new BrowserWindow(windowProperties)
                notificationWindow.setVisibleOnAllWorkspaces(true)
                notificationWindow.loadURL(getTemplatePath())
                notificationWindow.webContents.on('did-finish-load', function () {
                    // Done
                    notificationWindow.webContents.send('electron-notify-load-config', config)
                    resolve(notificationWindow)
                })
            }
        } else { // Or create a new window
            let windowProperties = config.defaultWindow
            windowProperties.width = config.width
            windowProperties.height = config.height
            notificationWindow = new BrowserWindow(windowProperties)
            notificationWindow.setVisibleOnAllWorkspaces(true)
            notificationWindow.loadURL(getTemplatePath())
            notificationWindow.webContents.on('did-finish-load', function () {
                // Done
                notificationWindow.webContents.send('electron-notify-load-config', config)
                resolve(notificationWindow)
            })
        }
    })
}

at this code notification try to setPosition and if it throw error catch and create window from start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants