aboutsummaryrefslogtreecommitdiffstats
path: root/generator/cppgenerator.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-09-13 17:43:16 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:14 -0300
commitc686942f6efbac4ac43cf859bfdd2c7209b783ea (patch)
tree39254222aca7f5bac8409a0078eaf5bbca2d1cf8 /generator/cppgenerator.cpp
parent987010cb2c5740bf1cb7af54b2c6dc3142c44805 (diff)
Fix bug 995 - "QDeclarativeView.itemAt returns faulty reference. (leading to SEGFAULT)"
Diffstat (limited to 'generator/cppgenerator.cpp')
-rw-r--r--generator/cppgenerator.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index b75a653bf..1beda78f7 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -3521,7 +3521,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
// Set typediscovery struct or fill the struct of another one
if (metaClass->isPolymorphic() && metaClass->baseClass()) {
- s << INDENT << "Shiboken::ObjectType::setTypeDiscoveryFunction(&" << cpythonTypeName(metaClass);
+ s << INDENT << "Shiboken::ObjectType::setTypeDiscoveryFunctionV2(&" << cpythonTypeName(metaClass);
s << ", &" << cpythonBaseName(metaClass) << "_typeDiscovery);" << endl << endl;
}
@@ -3619,22 +3619,14 @@ void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMeta
{
QString polymorphicExpr = metaClass->typeEntry()->polymorphicIdValue();
- s << "static SbkObjectType* " << cpythonBaseName(metaClass) << "_typeDiscovery(void* cptr, SbkObjectType* instanceType)\n{" << endl;
+ s << "static void* " << cpythonBaseName(metaClass) << "_typeDiscovery(void* cptr, SbkObjectType* instanceType)\n{" << endl;
- if (!metaClass->baseClass()) {
- s << INDENT << "TypeResolver* typeResolver = TypeResolver::get(typeid(*reinterpret_cast< ::"
- << metaClass->qualifiedCppName() << "*>(cptr)).name());" << endl;
- s << INDENT << "if (typeResolver)" << endl;
- {
- Indentation indent(INDENT);
- s << INDENT << "return reinterpret_cast<SbkObjectType*>(typeResolver->pythonType());" << endl;
- }
- } else if (!polymorphicExpr.isEmpty()) {
+ if (!polymorphicExpr.isEmpty()) {
polymorphicExpr = polymorphicExpr.replace("%1", " reinterpret_cast< ::" + metaClass->qualifiedCppName() + "*>(cptr)");
s << INDENT << " if (" << polymorphicExpr << ")" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "return &" << cpythonTypeName(metaClass) << ';' << endl;
+ s << INDENT << "return cptr;" << endl;
}
} else if (metaClass->isPolymorphic()) {
AbstractMetaClassList ancestors = getAllAncestors(metaClass);
@@ -3643,10 +3635,10 @@ void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMeta
continue;
if (ancestor->isPolymorphic()) {
s << INDENT << "if (instanceType == reinterpret_cast<SbkObjectType*>(Shiboken::SbkType< ::"
- << ancestor->qualifiedCppName() << " >()) && dynamic_cast< ::" << metaClass->qualifiedCppName()
- << "*>(reinterpret_cast< ::"<< ancestor->qualifiedCppName() << "*>(cptr)))" << endl;
+ << ancestor->qualifiedCppName() << " >()))" << endl;
Indentation indent(INDENT);
- s << INDENT << "return &" << cpythonTypeName(metaClass) << ';' << endl;
+ s << INDENT << "return dynamic_cast< ::" << metaClass->qualifiedCppName()
+ << "*>(reinterpret_cast< ::"<< ancestor->qualifiedCppName() << "*>(cptr));" << endl;
} else {
ReportHandler::warning(metaClass->qualifiedCppName() + " inherits from a non polymorphic type ("
+ ancestor->qualifiedCppName() + "), type discovery based on RTTI is "