Fix memory leak issues in minitor page

Issue was that QT (incorrectly?) asserted that there was a binding loop between width and height in the `NetworkMJPGImage` component. This caused the height to evalualte to `infinity`, making QT create a buffer with an infinite amount of memory. Solved by calculating a serpeate `img_scale_factor` which both the width and height uses.

CURA-11180
This commit is contained in:
c.lamboo 2023-10-19 11:53:41 +02:00
parent e5e941aeba
commit 0e1262126a
2 changed files with 24 additions and 15 deletions

View file

@ -1,6 +1,8 @@
# Copyright (c) 2018 Aldo Hoeben / fieldOfView
# NetworkMJPGImage is released under the terms of the LGPLv3 or higher.
from typing import Optional
from PyQt6.QtCore import QUrl, pyqtProperty, pyqtSignal, pyqtSlot, QRect, QByteArray
from PyQt6.QtGui import QImage, QPainter
from PyQt6.QtQuick import QQuickPaintedItem
@ -19,9 +21,9 @@ class NetworkMJPGImage(QQuickPaintedItem):
self._stream_buffer = QByteArray()
self._stream_buffer_start_index = -1
self._network_manager = None # type: QNetworkAccessManager
self._image_request = None # type: QNetworkRequest
self._image_reply = None # type: QNetworkReply
self._network_manager: Optional[QNetworkAccessManager] = None
self._image_request: Optional[QNetworkRequest] = None
self._image_reply: Optional[QNetworkReply] = None
self._image = QImage()
self._image_rect = QRect()