Fix bug#207, Add initQtMetaType class to libpyside.
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
bb32f63658
commit
34317b147f
1 changed files with 22 additions and 0 deletions
|
|
@ -37,12 +37,34 @@
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <pysidemacros.h>
|
#include <pysidemacros.h>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide
|
||||||
{
|
{
|
||||||
|
|
||||||
PYSIDE_API void init(PyObject *module);
|
PYSIDE_API void init(PyObject *module);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the type \p T was registered on Qt meta type system with Q_DECLARE_METATYPE macro, this class will initialize
|
||||||
|
* the meta type.
|
||||||
|
*
|
||||||
|
* Initialize a meta type means register it on Qt meta type system, Qt itself only do this on the first call of
|
||||||
|
* qMetaTypeId, and this is exactly what we do to init it. If we don't do that, calls to QMetaType::type("QMatrix2x2")
|
||||||
|
* could return zero, causing QVariant to not recognize some C++ types, like QMatrix2x2.
|
||||||
|
*/
|
||||||
|
template<typename T, bool OK = QMetaTypeId<T>::Defined >
|
||||||
|
struct initQtMetaType {
|
||||||
|
initQtMetaType()
|
||||||
|
{
|
||||||
|
qMetaTypeId<T>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Template specialization to do nothing when the type wasn't registered on Qt meta type system.
|
||||||
|
template<typename T>
|
||||||
|
struct initQtMetaType<T, false> {
|
||||||
|
};
|
||||||
|
|
||||||
} //namespace PySide
|
} //namespace PySide
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue