From bcf14392df0d83e79e10022112aea7dd91c5a1f9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 11 Jul 2023 12:08:18 +0200 Subject: [PATCH] rhi doc: Make getShader in the snippets more compact One line is better than three. Pick-to: 6.6 Change-Id: Ib738ec18b51accead3897b450b26207b3fba87d8 Reviewed-by: Laszlo Agocs --- src/gui/doc/snippets/rhioffscreen/main.cpp | 4 +--- src/gui/rhi/qrhi.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gui/doc/snippets/rhioffscreen/main.cpp b/src/gui/doc/snippets/rhioffscreen/main.cpp index b3fac4b520..217b07dcda 100644 --- a/src/gui/doc/snippets/rhioffscreen/main.cpp +++ b/src/gui/doc/snippets/rhioffscreen/main.cpp @@ -82,9 +82,7 @@ int main(int argc, char **argv) ps->setTargetBlends({ premulAlphaBlend }); static auto getShader = [](const QString &name) { QFile f(name); - if (f.open(QIODevice::ReadOnly)) - return QShader::fromSerialized(f.readAll()); - return QShader(); + return f.open(QIODevice::ReadOnly) ? QShader::fromSerialized(f.readAll()) : QShader(); }; ps->setShaderStages({ { QRhiShaderStage::Vertex, getShader(QLatin1String("color.vert.qsb")) }, diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index c0214debdf..fbc94d450e 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2029,9 +2029,7 @@ QDebug operator<<(QDebug dbg, const QRhiVertexInputLayout &v) QShader getShader(const QString &name) { QFile f(name); - if (f.open(QIODevice::ReadOnly)) - return QShader::fromSerialized(f.readAll()); - return QShader(); + return f.open(QIODevice::ReadOnly) ? QShader::fromSerialized(f.readAll()) : QShader(); } QShader vs = getShader("material.vert.qsb");