Fix some reference leaks.
Use QMetaType::Type values instead of obsolete QVariant::Type.
Use PyGILState_{Ensure,Release} to play well with recursive GIL acquisitions.
Wrap generic PyObjects in an opaque value that can be passed to/from QML safely.