From 34317b147f3c00b0ea81d79219183c1e96bc5533 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 20 May 2010 10:48:59 -0300 Subject: Fix bug#207, Add initQtMetaType class to libpyside. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Luciano Wolf --- libpyside/pyside.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libpyside/pyside.h b/libpyside/pyside.h index 3c1c0600c..2048265f4 100644 --- a/libpyside/pyside.h +++ b/libpyside/pyside.h @@ -37,12 +37,34 @@ #include #include +#include namespace PySide { 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::Defined > +struct initQtMetaType { + initQtMetaType() + { + qMetaTypeId(); + } +}; + +// Template specialization to do nothing when the type wasn't registered on Qt meta type system. +template +struct initQtMetaType { +}; + } //namespace PySide -- cgit v1.2.3