aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-07-20 10:34:02 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:03 -0300
commit419851922f8b12b0d93a6ce1f884f6975c1adfd7 (patch)
treef037612f02ee6d19d2de725f4265e8d28ac17e31 /generator
parent3e899a5e657b0f3a6bc38e788fc89c76c8962f47 (diff)
Check if need to use placement new for types that inherits QObject due to QML (qmlRegisterType) function.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Lauro Moura <lauro.neto@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 5a610b352..a0951cac6 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2190,13 +2190,19 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
if (func->isConstructor() || func->isCopyConstructor()) {
isCtor = true;
QString className = wrapperName(func->ownerClass());
- mc << "new ::" << className << '(';
+
if (func->isCopyConstructor() && maxArgs == 1) {
- mc << CPP_ARG0;
+ mc << "new ::" << className << '(' << CPP_ARG0 << ')';
} else {
- mc << userArgs.join(", ");
+ QString ctorCall = className + '(' + userArgs.join(", ") + ')';
+ if (usePySideExtensions() && func->ownerClass()->isQObject()) {
+ s << INDENT << "void* addr = PySide::nextQObjectMemoryAddr();" << endl;
+ mc << "addr ? new (addr) ::" << ctorCall << " : new ::" << ctorCall;
+ } else {
+ mc << "new ::" << ctorCall;
+ }
}
- mc << ')';
+
} else {
if (func->ownerClass()) {
if (!avoidProtectedHack() || !func->isProtected()) {
@@ -3711,7 +3717,8 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
if (usePySideExtensions() && metaClass->isQObject()) {
s << INDENT << "Shiboken::ObjectType::setSubTypeInitHook(&" << pyTypeName << ", &PySide::initQObjectSubType);" << endl;
- s << INDENT << "PySide::initDynamicMetaObject(&" << pyTypeName << ", &" << metaClass->qualifiedCppName() << "::staticMetaObject);" << endl;
+ s << INDENT << "PySide::initDynamicMetaObject(&" << pyTypeName << ", &::" << metaClass->qualifiedCppName()
+ << "::staticMetaObject, sizeof(::" << metaClass->qualifiedCppName() << "));" << endl;
}
s << '}' << endl << endl;