From 7bc6f1512b1febc026d81917f33b1ea90d23fe24 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 2 Jun 2010 07:57:07 -0300 Subject: Fixes code generation for classes with private destructors. This fix is specific for the cases when the "protected hack" is turned off. Also added some tests. --- shibokengenerator.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'shibokengenerator.cpp') diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index 5b85ef43a..16a216daf 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -178,9 +178,24 @@ bool ShibokenGenerator::shouldGenerateCppWrapper(const AbstractMetaClass* metaCl { bool result = metaClass->isPolymorphic() || metaClass->hasVirtualDestructor(); #ifdef AVOID_PROTECTED_HACK - result = result || metaClass->hasProtectedFunctions() || metaClass->hasProtectedDestructor(); + result = result || metaClass->hasProtectedFields() || metaClass->hasProtectedDestructor(); + if (!result && metaClass->hasProtectedFunctions()) { + int protectedFunctions = 0; + int protectedOperators = 0; + foreach (const AbstractMetaFunction* func, metaClass->functions()) { + if (!func->isProtected() || func->isSignal() || func->isModifiedRemoved()) + continue; + else if (func->isOperatorOverload()) + protectedOperators++; + else + protectedFunctions++; + } + result = result || (protectedFunctions > protectedOperators); + } +#else + result = result && !metaClass->hasPrivateDestructor(); #endif - return result && !metaClass->isNamespace() && !metaClass->hasPrivateDestructor(); + return result && !metaClass->isNamespace(); } QString ShibokenGenerator::wrapperName(const AbstractMetaClass* metaClass) -- cgit v1.2.3