aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken/typeresolver.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-03-18 17:35:16 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:18 -0300
commit0a34ce608e76a96c5bf9fbf8b363aaa0256e9396 (patch)
tree211867b05f7e7d6453686d67fbe18f93806ad11c /libshiboken/typeresolver.cpp
parenteb01027ab9266bc0d87fa396e419929567dadea1 (diff)
Fix bug 693 - "Heap corruption or double free reported on program exit"
Reviewer: Renato Araújo <renato.filho@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libshiboken/typeresolver.cpp')
-rw-r--r--libshiboken/typeresolver.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libshiboken/typeresolver.cpp b/libshiboken/typeresolver.cpp
index a195c8f08..343fe31a4 100644
--- a/libshiboken/typeresolver.cpp
+++ b/libshiboken/typeresolver.cpp
@@ -25,6 +25,7 @@
#include "sbkdbg.h"
#include <cstdlib>
#include <string>
+#include "basewrapper_p.h"
using namespace Shiboken;
@@ -68,6 +69,23 @@ TypeResolver* TypeResolver::createTypeResolver(const char* typeName,
tr->m_d->cppToPython = cppToPy;
tr->m_d->pythonToCpp = pyToCpp;
tr->m_d->pyType = pyType;
+
+ /*
+ * Note:
+ *
+ * Value types are also registered as object types, but the generator *always* first register the value
+ * type version in the TypeResolver and it *must* always do it! otherwise this code wont work.
+ *
+ * All this to not enter in this if several times, running all characters in the typeName string, etc...
+ * in other words... the nano seconds!!! somebody need to save them!
+ */
+ if (pyType && PyType_IsSubtype(pyType, reinterpret_cast<PyTypeObject*>(&SbkObject_Type))) {
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyType);
+ if (!sbkType->d->type_behaviour) {
+ int len = strlen(typeName);
+ sbkType->d->type_behaviour = typeName[len -1] == '*' ? BEHAVIOUR_OBJECTTYPE : BEHAVIOUR_VALUETYPE;
+ }
+ }
}
return tr;
}