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> | 2012-03-08 16:18:24 -0300 |
commit | 05aae9a59e9dbc8eec6eb33f86df8de4de71cc67 (patch) | |
tree | 729daae4c007a9fe81bcdfa5eac080771ef1e863 /libshiboken | |
parent | ebbc17b83cedcd5e41a402bef8ab294c2e9b0152 (diff) |
Fix bug 1013 - "connect to QSqlTableModel.primeInsert() causes crash"
Diffstat (limited to 'libshiboken')
-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 cdd379bc3..b095ba17b 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); |