From 9e03a219cb9128e7474582294435d7108beaff30 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 23 Nov 2023 19:06:26 +0100 Subject: [PATCH] platformsupport/scenes/opengl: don't crash when creating the texture fails --- .../scenes/opengl/basiceglsurfacetexture_wayland.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp b/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp index acf8af052a..39a5af7dcc 100644 --- a/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp +++ b/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp @@ -103,16 +103,18 @@ void BasicEGLSurfaceTextureWayland::updateShmTexture(GraphicsBuffer *buffer, con bool BasicEGLSurfaceTextureWayland::loadDmabufTexture(GraphicsBuffer *buffer) { - auto createTexture = [this](EGLImageKHR image, const QSize &size, bool isExternalOnly) { + auto createTexture = [this](EGLImageKHR image, const QSize &size, bool isExternalOnly) -> std::shared_ptr { if (Q_UNLIKELY(image == EGL_NO_IMAGE_KHR)) { qCritical(KWIN_OPENGL) << "Invalid dmabuf-based wl_buffer"; - return std::shared_ptr(); + return nullptr; } GLint target = isExternalOnly ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; auto texture = std::make_shared(target); texture->setSize(size); - texture->create(); + if (!texture->create()) { + return nullptr; + } texture->setWrapMode(GL_CLAMP_TO_EDGE); texture->setFilter(GL_LINEAR); texture->bind();