Skip to content

Fix libcamera id reference scope issues in CameraSource and SettingsMenu#239

Merged
saeugetier merged 5 commits into
192-direct-support-of-raspberry-pi-cameras-via-libcamerafrom
copilot/sub-pr-229-again
Jan 27, 2026
Merged

Fix libcamera id reference scope issues in CameraSource and SettingsMenu#239
saeugetier merged 5 commits into
192-direct-support-of-raspberry-pi-cameras-via-libcamerafrom
copilot/sub-pr-229-again

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 27, 2026

Both CameraSource.qml and SettingsMenu.qml were directly referencing the libcamera id or module without proper instances, causing runtime failures since QML ids are scoped to their defining file and importing a module doesn't create an instance.

Changes

CameraSource.qml

  • Added property threading: Pass libcamera instance through component hierarchy via properties:

    Application → ApplicationFlowForm → SnapshotMenuForm → CameraRenderer → CameraSource
    
  • Updated CameraSource.qml: Replaced all bare libcamera references with cameraSource.libcamera property access:

    • Method calls: availableCameras(), startCamera(), stopCamera(), captureImage()
    • Signal connections: onErrorOccurred, onImageCaptured
    • State bindings: videoFrameInput property changes
    • Added null checks for safe access

Example change:

// Before: undefined reference
Connections {
    target: libcamera
    function onImageCaptured(image) { ... }
}

// After: property-based access
Connections {
    target: cameraSource.libcamera
    function onImageCaptured(image) { ... }
}

SettingsMenu.qml

  • Added property threading: Pass libcamera instance through component hierarchy via properties:

    Application → ApplicationFlowForm → SettingsMenu → SettingsMenuForm
    
  • Updated SettingsMenu.qml: Replaced bare libcamera reference with form.libcamera property access:

    • Method calls: availableCameras() for camera enumeration
    • Added null checks for safe access

This approach maintains a single Libcamera instance throughout the application, defined in Application.qml and passed as a property to all components that need it. Properties are declared in UI form files (*Form.ui.qml) to follow QML inheritance patterns and avoid shadowing in derived components.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 27, 2026 18:50
Co-authored-by: saeugetier <1408260+saeugetier@users.noreply.github.com>
Co-authored-by: saeugetier <1408260+saeugetier@users.noreply.github.com>
Copilot AI changed the title [WIP] Update libcamera based camera implementation Fix libcamera id reference scope issue in CameraSource Jan 27, 2026
Copilot AI requested a review from saeugetier January 27, 2026 18:53
@saeugetier
Copy link
Copy Markdown
Owner

@copilot please fix this comment as well #229 (comment)

Co-authored-by: saeugetier <1408260+saeugetier@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Jan 27, 2026

@copilot please fix this comment as well #229 (comment)

Fixed in commit 759e302. Added a local Libcamera instance to SettingsMenu.qml (following the same pattern as GPhotoCamera), so libcamera.availableCameras() now has a valid instance to reference.

Copilot AI changed the title Fix libcamera id reference scope issue in CameraSource Fix libcamera id reference scope issues in CameraSource and SettingsMenu Jan 27, 2026
Comment thread qml/SettingsMenu.qml Outdated
id: gphotoCamera
}

Libcamera {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the instance of libcamera should come from application via property

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 644d198. Removed the local Libcamera instance and now SettingsMenu receives the libcamera instance from Application.qml via property (Application → ApplicationFlow → ApplicationFlowForm → SettingsMenu). Updated the reference to use form.libcamera with null check.

Co-authored-by: saeugetier <1408260+saeugetier@users.noreply.github.com>
Copilot AI requested a review from saeugetier January 27, 2026 19:07
@saeugetier saeugetier marked this pull request as ready for review January 27, 2026 19:29
Copy link
Copy Markdown
Owner

@saeugetier saeugetier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@saeugetier saeugetier merged commit b4b9484 into 192-direct-support-of-raspberry-pi-cameras-via-libcamera Jan 27, 2026
2 checks passed
@saeugetier saeugetier deleted the copilot/sub-pr-229-again branch January 27, 2026 19:32
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

Successfully merging this pull request may close these issues.

2 participants