fix: crash when failed to get devices in desktopCapturer (#17557)
* fix: crash when failed to get devices in desktopCapturer * return after emit
This commit is contained in:
parent
2ad942323c
commit
c2c3a04628
2 changed files with 14 additions and 3 deletions
|
@ -165,8 +165,12 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
|||
std::vector<std::string> device_names;
|
||||
// Crucially, this list of device names will be in the same order as
|
||||
// |media_list_sources|.
|
||||
webrtc::DxgiDuplicatorController::Instance()->GetDeviceNames(
|
||||
&device_names);
|
||||
if (!webrtc::DxgiDuplicatorController::Instance()->GetDeviceNames(
|
||||
&device_names)) {
|
||||
Emit("error", "Failed to get sources.");
|
||||
return;
|
||||
}
|
||||
|
||||
int device_name_index = 0;
|
||||
for (auto& source : screen_sources) {
|
||||
const auto& device_name = device_names[device_name_index++];
|
||||
|
|
|
@ -26,7 +26,8 @@ ipcMainUtils.handle('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', (event, cap
|
|||
thumbnailSize,
|
||||
fetchWindowIcons
|
||||
},
|
||||
resolve
|
||||
resolve,
|
||||
reject
|
||||
}
|
||||
requestsQueue.push(request)
|
||||
if (requestsQueue.length === 1) {
|
||||
|
@ -46,6 +47,12 @@ desktopCapturer.emit = (event, name, sources, fetchWindowIcons) => {
|
|||
const handledRequest = requestsQueue.shift()
|
||||
const unhandledRequestsQueue = []
|
||||
|
||||
if (name === 'error') {
|
||||
const error = sources
|
||||
handledRequest.reject(error)
|
||||
return
|
||||
}
|
||||
|
||||
const result = sources.map(source => {
|
||||
return {
|
||||
id: source.id,
|
||||
|
|
Loading…
Reference in a new issue