Merge pull request #4669 from Ultimaker/CURA-5821_fix_camera_memory_leak

Cura 5821 fix camera memory leak
This commit is contained in:
Remco Burema 2018-10-26 15:00:03 +02:00 committed by GitHub
commit de680f4aac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 26 deletions

View file

@ -10,7 +10,7 @@ Component {
height: maximumHeight;
width: maximumWidth;
Image {
Cura.CameraView {
id: cameraImage;
anchors {
horizontalCenter: parent.horizontalCenter;
@ -21,7 +21,7 @@ Component {
OutputDevice.activePrinter.camera.start();
}
}
height: Math.floor((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width);
height: Math.floor((imageHeight === 0 ? 600 * screenScaleFactor : imageHeight) * width / imageWidth);
onVisibleChanged: {
if (visible) {
if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null) {
@ -33,14 +33,20 @@ Component {
}
}
}
source: {
if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null && OutputDevice.activePrinter.camera.latestImage) {
return OutputDevice.activePrinter.camera.latestImage;
}
return "";
}
width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth);
width: Math.min(imageWidth === 0 ? 800 * screenScaleFactor : imageWidth, maximumWidth);
z: 1;
Connections
{
target: OutputDevice.activePrinter.camera;
onNewImage:
{
if (cameraImage.visible) {
cameraImage.image = OutputDevice.activePrinter.camera.latestImage;
cameraImage.update();
}
}
}
}
}
}

View file

@ -5,6 +5,7 @@ import QtQuick 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import UM 1.3 as UM
import Cura 1.0 as Cura
Item {
property var camera: null;
@ -33,11 +34,11 @@ Item {
z: 999;
}
Image {
Cura.CameraView {
id: cameraImage
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
height: Math.round((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width);
height: Math.round((imageHeight === 0 ? 600 * screenScaleFactor : imageHeight) * width / imageWidth);
onVisibleChanged: {
if (visible) {
if (camera != null) {
@ -49,13 +50,18 @@ Item {
}
}
}
source: {
if (camera != null && camera.latestImage != null) {
return camera.latestImage;
Connections
{
target: camera
onNewImage: {
if (cameraImage.visible) {
cameraImage.image = camera.latestImage;
cameraImage.update();
}
}
return "";
}
width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth);
width: Math.min(imageWidth === 0 ? 800 * screenScaleFactor : imageWidth, maximumWidth);
z: 1
}