diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-07-21 04:45:56 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:04 -0300 |
commit | d59f29f9d51928ab96dd65953e791d658156b312 (patch) | |
tree | eedc45f5062533ffafdc25b758d2d36af88e0d4e /generator | |
parent | d670e94717bcd433690eda116afd4d18234e029a (diff) |
std::auto_ptr is safer than relying in an if clause at the end of the code block.
Diffstat (limited to 'generator')
-rw-r--r-- | generator/cppgenerator.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index 52925f3b2..527ca6f8c 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -21,6 +21,8 @@ * */ +#include <memory> + #include "cppgenerator.h" #include "shibokennormalize_p.h" #include <reporthandler.h> @@ -1908,10 +1910,13 @@ void CppGenerator::writeSingleFunctionCall(QTextStream& s, const OverloadData& o QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1); const AbstractMetaType* argType = 0; - if (typeReplaced.isEmpty()) + std::auto_ptr<const AbstractMetaType> argType_autoptr; + if (typeReplaced.isEmpty()) { argType = arg->type(); - else + } else { argType = buildAbstractMetaTypeFromString(typeReplaced); + argType_autoptr = std::auto_ptr<const AbstractMetaType>(argType); + } if (argType) { QString argName = QString(CPP_ARG"%1").arg(i - removedArgs); @@ -1919,10 +1924,6 @@ void CppGenerator::writeSingleFunctionCall(QTextStream& s, const OverloadData& o QString defaultValue = guessScopeForDefaultValue(func, arg); writeArgumentConversion(s, argType, argName, pyArgName, implementingClass, defaultValue); - - // Free a custom type created by buildAbstractMetaTypeFromString. - if (argType != arg->type()) - delete argType; } } |