[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: rearrange variables in RoundImage
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sat Mar 23 09:31:50 UTC 2024
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
58a7aec1 by Prince Gupta at 2024-03-23T09:13:35+00:00
qt: rearrange variables in RoundImage
reduces padding
- - - - -
cc922574 by Prince Gupta at 2024-03-23T09:13:35+00:00
qt: fix possible infinite loading in RoundImage
correctly handle error for custom generators
- - - - -
dafc146c by Prince Gupta at 2024-03-23T09:13:35+00:00
qt: fix leak of network resources from RoundImage
also add documentation to address ambiguity in object ownership
- - - - -
2 changed files:
- modules/gui/qt/widgets/native/roundimage.cpp
- modules/gui/qt/widgets/native/roundimage.hpp
Changes:
=====================================
modules/gui/qt/widgets/native/roundimage.cpp
=====================================
@@ -104,7 +104,15 @@ namespace
class ImageReader : public AsyncTask<QImage>
{
public:
- // requestedSize is only taken as hint, the Image is resized with PreserveAspectCrop
+ /**
+ * @brief ImageReader
+ * @param device i/o source to read from, ImageReader doesn't take owner ship of the device
+ * parent must make sure availability of device through out the lifetime of this instance
+ *
+ * @param requestedSize only taken as hint, the Image is resized with PreserveAspectCrop
+ *
+ * @param radius
+ */
ImageReader(QIODevice *device, QSize requestedSize, const qreal radius)
: device {device}
, requestedSize {requestedSize}
@@ -182,11 +190,19 @@ namespace
class NetworkImageResponse : public QQuickImageResponse
{
public:
+ /**
+ * @brief NetworkImageResponse
+ * @param reply - Network reply to read from, NetworkImageResponse takes ownership of this object
+ * @param requestedSize - passed to ImageReader class
+ * @param radius - passed to ImageReader class
+ */
NetworkImageResponse(QNetworkReply *reply, QSize requestedSize, const qreal radius)
: reply {reply}
, requestedSize {requestedSize}
, radius {radius}
{
+ reply->setParent(this);
+
QObject::connect(reply, &QNetworkReply::finished
, this, &NetworkImageResponse::handleNetworkReplyFinished);
}
@@ -216,6 +232,8 @@ namespace
{
error = reply->errorString();
emit finished();
+
+ releaseNetworkReply();
return;
}
@@ -226,12 +244,20 @@ namespace
error = reader->errorString();
reader.reset();
+ releaseNetworkReply();
+
emit finished();
});
reader->start(*QThreadPool::globalInstance());
}
+ void releaseNetworkReply()
+ {
+ reply->deleteLater();
+ reply = nullptr;
+ }
+
QNetworkReply *reply;
QSize requestedSize;
qreal radius;
@@ -283,7 +309,11 @@ namespace
auto textureFactory = std::unique_ptr<QQuickTextureFactory>(response->textureFactory());
auto img = !textureFactory ? QImage {} : textureFactory->image();
if (!textureFactory || img.isNull())
+ {
+ // source response failed, signal to parent
+ emit finished();
return;
+ }
response->disconnect(this);
response->deleteLater();
=====================================
modules/gui/qt/widgets/native/roundimage.hpp
=====================================
@@ -88,19 +88,17 @@ private slots:
void onRequestCompleted(Status status, const QImage& image);
private:
+ Status m_status = Status::Null;
+ bool m_QSGCustomGeometry = false;
+ bool m_dirty = false;
+ bool m_enqueuedGeneration = false;
+
QUrl m_source;
qreal m_radius = 0.0;
qreal m_dpr = 1.0; // device pixel ratio
- Status m_status = Status::Null;
-
- bool m_QSGCustomGeometry = false;
QImage m_roundImage;
- bool m_dirty = false;
-
std::shared_ptr<RoundImageRequest> m_activeImageResponse;
-
- bool m_enqueuedGeneration = false;
};
#endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/44879313bab5b7208b12cb4968cf03a6f521e531...dafc146cf89f9d32c8b49905a409a6ccb2d73428
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/44879313bab5b7208b12cb4968cf03a6f521e531...dafc146cf89f9d32c8b49905a409a6ccb2d73428
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list