fix: memory leak in desktopCapturer.getSources (#27031)
This commit is contained in:
parent
8f9058ea72
commit
6a3679dc55
1 changed files with 4 additions and 1 deletions
|
@ -48,6 +48,9 @@ export const getSourcesImpl = (event: Electron.IpcMainEvent | null, args: Electr
|
||||||
}
|
}
|
||||||
// Remove from currentlyRunning once we resolve or reject
|
// Remove from currentlyRunning once we resolve or reject
|
||||||
currentlyRunning = currentlyRunning.filter(running => running.options !== options);
|
currentlyRunning = currentlyRunning.filter(running => running.options !== options);
|
||||||
|
if (event) {
|
||||||
|
event.sender.removeListener('destroyed', stopRunning);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
capturer._onerror = (error: string) => {
|
capturer._onerror = (error: string) => {
|
||||||
|
@ -66,7 +69,7 @@ export const getSourcesImpl = (event: Electron.IpcMainEvent | null, args: Electr
|
||||||
// reference to emit and the capturer itself so that it never dispatches
|
// reference to emit and the capturer itself so that it never dispatches
|
||||||
// back to the renderer
|
// back to the renderer
|
||||||
if (event) {
|
if (event) {
|
||||||
event.sender.once('destroyed', () => stopRunning());
|
event.sender.once('destroyed', stopRunning);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue