From 45c476da3a700a68e4890f06504c7f2c09608ba9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 3 Jun 2021 16:34:28 +0400 Subject: [PATCH] Fix working with OpenGL images. --- ui/gl/gl_image.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/gl/gl_image.cpp b/ui/gl/gl_image.cpp index 79557c50..1e8daa7a 100644 --- a/ui/gl/gl_image.cpp +++ b/ui/gl/gl_image.cpp @@ -69,7 +69,7 @@ void Image::bind(QOpenGLFunctions &f, QSize subimage) { && subimage.height() <= _image.height()); _textures.ensureCreated(f); - if (subimage.isNull()) { + if (!subimage.isValid()) { subimage = _image.size(); } if (subimage.isEmpty()) { @@ -127,6 +127,12 @@ TexturedRect Image::texturedRect( const auto visible = clip.isNull() ? geometry : clip.intersected(geometry); + if (visible.isEmpty()) { + return TexturedRect{ + .geometry = Rect(visible), + .texture = Rect(0., 0., 0., 0.), + }; + } const auto xFactor = texture.width() / geometry.width(); const auto yFactor = texture.height() / geometry.height(); const auto usedTexture = QRect(