Bug 510091

Summary: [KConfig Compiler] Incorrect forward declaration of QQmlEngine and QJSEngine inside namespace.
Product: [Frameworks and Libraries] frameworks-kconfig Reporter: Trần Nam Tuấn (Bill) <tuantran1632001>
Component: generalAssignee: Matthew Dawson <matthew>
Status: CONFIRMED ---    
Severity: normal CC: kdelibs-bugs-null, nicolas.fella
Priority: NOR    
Version First Reported In: 6.18.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Trần Nam Tuấn (Bill) 2025-09-30 08:41:16 UTC
When using KConfig Compiler with NameSpace and QmlRegistration options enabled, the forward declaration of QQmlEngine and QJSEngine are placed inside the namespace. If the Singleton option is enabled, the final code fails to compile. Specifically, these line in the generated source code:

```
using namespace NameSpace;

// ...

Config *Config::create(QQmlEngine *, QJSEngine *)
{
    // Error: Incomplete type 'Namespace::QQmlEngine' named in nested  name specifier
    QQmlEngine::setObjectOwnership(self(), QQmlEngine::CppOwnership);
    return self();
}
```
Comment 1 Trần Nam Tuấn (Bill) 2025-09-30 08:43:50 UTC
(In reply to Trần Nam Tuấn (Bill) from comment #0)
> When using KConfig Compiler with NameSpace and QmlRegistration options
> enabled, the forward declaration of QQmlEngine and QJSEngine are placed
> inside the namespace. If the Singleton option is enabled, the final code
> fails to compile.
>

Rephrasing: When using KConfig Compiler with NameSpace, Singleton and QmlRegistration options enabled, the forward declaration of QQmlEngine and QJSEngine are placed inside the namespace, which causes the final code to fail to compile.