Each page can now implement cameraError() to do any cleanup when we get an error
signal batteryLow
+ function cameraError() {
+ // Nothing
+ }
+
function policyLost() {
// Nothing
}
orientationLock: PageOrientation.LockLandscape
+ function cameraError() {
+ mountProtector.unlock();
+ }
+
function captureImage() {
if (!checkBattery()) {
showError(qsTr("Not enough battery to capture images."));
property Camera camera: null
property Item currentPage: pageStack.currentPage
+ property bool error: false
onCurrentPageChanged: {
if (state == "on" || state == "policyLost") {
}
function startCamera() {
+ if (error) {
+ return;
+ }
+
if (!policy.acquire(currentPage.policyMode)) {
console.log("Failed to acquire policy resources");
return;
function stopCamera() {
if (camera.stop(false)) {
policy.acquire(CameraResources.None);
+ error = false;
}
}
// when they become available
pageStack.currentPage.policyLost();
camera.stop(true);
+ error = false;
}
state: "off"
CameraPage {
id: page
modesVisible: false
+ property bool error: false
+
+ policyMode: CameraResources.Recording
+
+ controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !error
+
+ orientationLock: PageOrientation.LockLandscape
function policyLost() {
page.stopRecording();
}
+ function cameraError() {
+ error = true;
+ page.stopRecording();
+ }
+
Component.onDestruction: videoMode.stopRecording();
onStatusChanged: {
function stopRecording() {
mountProtector.unlock();
- pageStack.pop(undefined, true);
+ // Something is fishy here but if there is an error
+ // and we use immediate mode then the page never gets destroyed.
+ pageStack.pop(undefined, error ? false : true);
}
- policyMode: CameraResources.Recording
-
- controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning
-
- orientationLock: PageOrientation.LockLandscape
-
DisplayState {
inhibitDim: true
}
}
*/
onError: {
-// TODO: seems we freeze here somehow
+ if (pipelineManager.error) {
+ // Ignore any subsequent errors.
+ // Killing pulseaudio while recording will lead to an
+ // infinite supply of errors which will break the UI
+ // if we show a banner for each.
+ return;
+ }
+
+ pipelineManager.error = true;
+ pageStack.currentPage.cameraError();
console.log("Camera error (" + code + "): " + message + " " + debug);
showError(qsTr("Camera error. Please restart the application."));
- cam.stop();
- mountProtector.unlock();
+
+ // We cannot stop camera here. Seems there is a race condition somewhere
+ // which leads to a freeze if we do so.
}
onRunningChanged: {