rhi: Make unreleased resource warnings available in release builds
...but tie to an environment variable still. When destroying a QRhi object, it has the ability to print warnings for each QRhiResource that got created from the QRhi and is still alive. This includes only QRhiResources that own native objects underneath. It can be handy to enable this in release builds as well. Therefore, make this possible by setting QT_RHI_LEAK_CHECK=1. In debug builds this continues to be always on. Pick-to: 6.1 Change-Id: I5283676594284fadf2adf4f123b4fc6adb6db1f7 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
63a0d263cf
commit
8a0dd61911
@ -4276,7 +4276,6 @@ QRhiResource::Type QRhiCommandBuffer::resourceType() const
|
||||
return CommandBuffer;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
static const char *resourceTypeStr(QRhiResource *res)
|
||||
{
|
||||
switch (res->resourceType()) {
|
||||
@ -4310,7 +4309,6 @@ static const char *resourceTypeStr(QRhiResource *res)
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
QRhiImplementation::~QRhiImplementation()
|
||||
{
|
||||
@ -4320,7 +4318,13 @@ QRhiImplementation::~QRhiImplementation()
|
||||
// this far with some backends where the allocator or the api may check
|
||||
// and freak out for unfreed graphics objects in the derived dtor already.
|
||||
#ifndef QT_NO_DEBUG
|
||||
if (!resources.isEmpty()) {
|
||||
// debug builds: just do it always
|
||||
static bool leakCheck = true;
|
||||
#else
|
||||
// release builds: opt-in
|
||||
static bool leakCheck = qEnvironmentVariableIntValue("QT_RHI_LEAK_CHECK");
|
||||
#endif
|
||||
if (leakCheck && !resources.isEmpty()) {
|
||||
qWarning("QRhi %p going down with %d unreleased resources that own native graphics objects. This is not nice.",
|
||||
q, int(resources.count()));
|
||||
for (QRhiResource *res : qAsConst(resources)) {
|
||||
@ -4328,7 +4332,6 @@ QRhiImplementation::~QRhiImplementation()
|
||||
res->m_rhi = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QRhiImplementation::isCompressedFormat(QRhiTexture::Format format) const
|
||||
|
Loading…
Reference in New Issue
Block a user