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 <laszlo.agocs@qt.io>
This commit is contained in:
Laszlo Agocs 2023-07-11 12:08:18 +02:00
parent ec2faefbc2
commit bcf14392df
2 changed files with 2 additions and 6 deletions

View File

@ -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")) },

View File

@ -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");