Skip to content

Commit

Permalink
Merge pull request desktop#14733 from tsvetilian-ty/fix-leaked-process
Browse files Browse the repository at this point in the history
Fix leaked background process on Windows
  • Loading branch information
sergiou87 committed Jun 9, 2022
1 parent 8c41896 commit 8331262
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"codemirror-mode-elixir": "^1.1.2",
"compare-versions": "^3.6.0",
"deep-equal": "^1.0.1",
"desktop-notifications": "^0.2.1",
"desktop-notifications": "^0.2.2",
"desktop-trampoline": "desktop/desktop-trampoline#v0.9.8",
"dexie": "^2.0.0",
"dompurify": "^2.3.3",
Expand Down
6 changes: 5 additions & 1 deletion app/src/main-process/app-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import * as path from 'path'
import windowStateKeeper from 'electron-window-state'
import * as ipcMain from './ipc-main'
import * as ipcWebContents from './ipc-webcontents'
import { installNotificationCallback } from './notifications'
import {
installNotificationCallback,
terminateDesktopNotifications,
} from './notifications'

export class AppWindow {
private window: Electron.BrowserWindow
Expand Down Expand Up @@ -107,6 +110,7 @@ export class AppWindow {
}
nativeTheme.removeAllListeners()
autoUpdater.removeAllListeners()
terminateDesktopNotifications()
})

if (__WIN32__) {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main-process/notifications.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
initializeNotifications,
onNotificationEvent,
terminateNotifications,
} from 'desktop-notifications'
import { BrowserWindow } from 'electron'
import { findToastActivatorClsid } from '../lib/find-toast-activator-clsid'
Expand Down Expand Up @@ -35,6 +36,10 @@ export function initializeDesktopNotifications() {
initializeNotifications({ toastActivatorClsid: windowsToastActivatorClsid })
}

export function terminateDesktopNotifications() {
terminateNotifications()
}

export function installNotificationCallback(window: BrowserWindow) {
onNotificationEvent<DesktopAliveEvent>((event, id, userInfo) => {
ipcWebContents.send(
Expand Down
8 changes: 4 additions & 4 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@ delegates@^1.0.0:
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=

desktop-notifications@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/desktop-notifications/-/desktop-notifications-0.2.1.tgz#ff934e45ef6b47cfbbd6c596c759fc91b96ab753"
integrity sha512-ssB7SYsWlVgFCN/4KE5QIHM1hH4PXGHmlIYpUa4xR7WDHcjMEU6vrnrAFWx9SnPLVkCNDiWRwSDejlS1VF9BHw==
desktop-notifications@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/desktop-notifications/-/desktop-notifications-0.2.2.tgz#197a32ee504a894ad074793dab285681c533e5ac"
integrity sha512-XMnxdWV6ZfiCzLZNC00n6h30Jt3z8yv21FAPBt/kK6hANI0PaoYWsRKEYya0zMUAX/9lrh429R5OtRGOKWZQSw==
dependencies:
node-addon-api "^5.0.0"
prebuild-install "^7.0.1"
Expand Down

0 comments on commit 8331262

Please sign in to comment.