diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-10-28 15:12:19 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-10-28 15:12:19 -0200 |
commit | 3a774ef95e9d39576d0e56a2c71dac7a26cc1948 (patch) | |
tree | b50b79813f17e00a7413920904e4ffbb559e9079 | |
parent | a2d89af7970a7c870ce9ed22138ef106c71f3257 (diff) | |
download | shiboken-3a774ef95e9d39576d0e56a2c71dac7a26cc1948.tar.gz shiboken-3a774ef95e9d39576d0e56a2c71dac7a26cc1948.tar.xz shiboken-3a774ef95e9d39576d0e56a2c71dac7a26cc1948.zip |
Fix bug 1013 - "connect to QSqlTableModel.primeInsert() causes crash"
-rw-r--r-- | libshiboken/typeresolver.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libshiboken/typeresolver.h b/libshiboken/typeresolver.h index cdd379bc..b095ba17 100644 --- a/libshiboken/typeresolver.h +++ b/libshiboken/typeresolver.h @@ -48,6 +48,14 @@ inline PyObject* objectTypeToPython(void* cptr) return Shiboken::Converter<T*>::toPython(*reinterpret_cast<T**>(cptr)); } +template <typename T> +inline PyObject* referenceTypeToPython(void* cptr) +{ + // cptr comes the same way it come when we have a value type, but + // we deliver a Python object of a reference + return Shiboken::Converter<T&>::toPython(*reinterpret_cast<T*>(cptr)); +} + /** * \internal This function is not part of the public API. * Initialize the TypeResource internal cache. @@ -81,6 +89,16 @@ public: return createTypeResolver(typeName, &objectTypeToPython<T>, &pythonToObjectType<T>, SbkType<T>()); } + /** + * This kind of type resolver is used only when we have a signal with a reference in their arguments + * like on QSqlTableModel::primeInsert. + */ + template<typename T> + static TypeResolver* createReferenceTypeResolver(const char* typeName) + { + return createTypeResolver(typeName, &referenceTypeToPython<T>, &pythonToValueType<T>, SbkType<T>()); + } + static Type getType(const char* name); static TypeResolver* get(const char* typeName); |