diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-11-14 10:15:26 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-11-14 11:05:48 +0100 |
commit | 6fa2ee7f4a40de6a6faed2227b39533b0ff79803 (patch) | |
tree | b63b8d1bfd429cfdaf1782739d1c6e1fd1daa40f /src/gui/rhi/qshader.cpp | |
parent | 244daf4cfc44587c8c7c87e481688e840cc21c77 (diff) | |
download | qtbase-6fa2ee7f4a40de6a6faed2227b39533b0ff79803.tar.gz |
Fix crash when resetting a QShader
shader = QShader() would crash because qAtomicAssign() requires that
the other's d-pointer is non-null. Follows pattern from other usages
in Qt.
Pick-to: 6.2 6.4
Fixes: QTBUG-108121
Change-Id: I57d25a804340839d03f9dadcbd44e956fb259c30
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi/qshader.cpp')
-rw-r--r-- | src/gui/rhi/qshader.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 85a0271272..e27ac8365e 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -241,7 +241,13 @@ QShader::QShader(const QShader &other) QShader &QShader::operator=(const QShader &other) { if (d) { - qAtomicAssign(d, other.d); + if (other.d) { + qAtomicAssign(d, other.d); + } else { + if (!d->ref.deref()) + delete d; + d = nullptr; + } } else if (other.d) { other.d->ref.ref(); d = other.d; |