From 4f8080ead2c5ecea536cd183017ff463f5d90b87 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 10 Mar 2025 14:10:24 -0700 Subject: [PATCH] Fix material instance check log when destroying material When the feature flags assert_destroy_material_before_material_instance is disabled, we emit a log instead of an assert. Unfortunately this log would be emitted even when all material instances were destroyed. --- filament/src/details/Material.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/filament/src/details/Material.cpp b/filament/src/details/Material.cpp index 13dfc3c245..aaebe3d0dd 100644 --- a/filament/src/details/Material.cpp +++ b/filament/src/details/Material.cpp @@ -388,12 +388,13 @@ void FMaterial::terminate(FEngine& engine) { << "destroying material \"" << this->getName().c_str_safe() << "\" but " << pos->second.size() << " instances still alive."; } else { - utils::slog.e << "destroying material \"" << this->getName().c_str_safe() << "\" but " - << pos->second.size() << " instances still alive."; + if (UTILS_UNLIKELY(!pos->second.empty())) { + slog.e << "destroying material \"" << this->getName().c_str_safe() << "\" but " + << pos->second.size() << " instances still alive." << io::endl; + } } } - #if FILAMENT_ENABLE_MATDBG // Unregister the material with matdbg. matdbg::DebugServer* server = engine.debug.server;