From cb24f191fd07a379a2f8c06e29c20de3e4a596bf Mon Sep 17 00:00:00 2001 From: D8H Date: Wed, 22 Jan 2025 17:17:39 +0100 Subject: [PATCH] Fix used extension check false positive from usused object or behavior events (#7331) - Don't show in changelog --- .../IDE/Events/UsedExtensionsFinder.cpp | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Core/GDCore/IDE/Events/UsedExtensionsFinder.cpp b/Core/GDCore/IDE/Events/UsedExtensionsFinder.cpp index f66d88fe2c07..5fb3c7458819 100644 --- a/Core/GDCore/IDE/Events/UsedExtensionsFinder.cpp +++ b/Core/GDCore/IDE/Events/UsedExtensionsFinder.cpp @@ -69,9 +69,16 @@ bool UsedExtensionsFinder::DoVisitInstruction(gd::Instruction& instruction, project.GetCurrentPlatform(), instruction.GetType()) : gd::MetadataProvider::GetExtensionAndActionMetadata( project.GetCurrentPlatform(), instruction.GetType()); - result.AddUsedExtension(metadata.GetExtension()); - for (auto&& includeFile : metadata.GetMetadata().GetIncludeFiles()) { - result.AddUsedIncludeFiles(includeFile); + // Unused event-based objects or events-based behaviors may use object and + // behavior instructions that should not be detected as extension usage. + // The extension of actually used objects and behaviors will be detected on + // scene objects. This is why object or behavior instructions usually don't + // have any import. + if (!metadata.GetMetadata().GetIncludeFiles().empty()) { + result.AddUsedExtension(metadata.GetExtension()); + for (auto &&includeFile : metadata.GetMetadata().GetIncludeFiles()) { + result.AddUsedIncludeFiles(includeFile); + } } gd::ParameterMetadataTools::IterateOverParameters( @@ -199,9 +206,16 @@ void UsedExtensionsFinder::OnVisitFunctionCallNode(FunctionCallNode& node) { return; } - result.AddUsedExtension(metadata.GetExtension()); - for (auto&& includeFile : metadata.GetMetadata().GetIncludeFiles()) { - result.AddUsedIncludeFiles(includeFile); + // Unused event-based objects or events-based behaviors may use object and + // behavior expressions that should not be detected as extension usage. + // The extension of actually used objects and behaviors will be detected on + // scene objects. This is why object or behavior expressions usually don't + // have any import. + if (!metadata.GetMetadata().GetIncludeFiles().empty()) { + result.AddUsedExtension(metadata.GetExtension()); + for (auto &&includeFile : metadata.GetMetadata().GetIncludeFiles()) { + result.AddUsedIncludeFiles(includeFile); + } } };