Skip to content

Commit 48167ff

Browse files
committed
Merge pull request #100540 from j20001970/cameraserver-check-feed-type
Camera: Skip non platform-specifc `CameraFeed` types in Linux/macOS driver
2 parents e69a561 + 9655d7d commit 48167ff

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

modules/camera/camera_linux.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ void CameraLinux::_update_devices() {
5252

5353
for (int i = feeds.size() - 1; i >= 0; i--) {
5454
Ref<CameraFeedLinux> feed = (Ref<CameraFeedLinux>)feeds[i];
55+
if (feed.is_null()) {
56+
continue;
57+
}
5558
String device_name = feed->get_device_name();
5659
if (!_is_active(device_name)) {
5760
remove_feed(feed);
@@ -84,6 +87,9 @@ void CameraLinux::_update_devices() {
8487
bool CameraLinux::_has_device(const String &p_device_name) {
8588
for (int i = 0; i < feeds.size(); i++) {
8689
Ref<CameraFeedLinux> feed = (Ref<CameraFeedLinux>)feeds[i];
90+
if (feed.is_null()) {
91+
continue;
92+
}
8793
if (feed->get_device_name() == p_device_name) {
8894
return true;
8995
}

modules/camera/camera_macos.mm

+6
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ - (void)dealloc {
323323
// remove devices that are gone..
324324
for (int i = feeds.size() - 1; i >= 0; i--) {
325325
Ref<CameraFeedMacOS> feed = (Ref<CameraFeedMacOS>)feeds[i];
326+
if (feed.is_null()) {
327+
continue;
328+
}
326329

327330
if (![devices containsObject:feed->get_device()]) {
328331
// remove it from our array, this will also destroy it ;)
@@ -334,6 +337,9 @@ - (void)dealloc {
334337
bool found = false;
335338
for (int i = 0; i < feeds.size() && !found; i++) {
336339
Ref<CameraFeedMacOS> feed = (Ref<CameraFeedMacOS>)feeds[i];
340+
if (feed.is_null()) {
341+
continue;
342+
}
337343
if (feed->get_device() == device) {
338344
found = true;
339345
};

0 commit comments

Comments
 (0)