Few month back, I wrote instructions to build PyQT for Maya 2014, but couple of weeks later someone came with a problem in using SIP with Maya. The issue was that Maya is crashing when someone tries to get the Maya handle and bind it using sip. I.e.:
import sip as _sip import PyQt4.QtCore as _QtCore import PyQt4.QtGui as _QtGui import maya.OpenMayaUI as _OpenMayaUI mainWindow = _sip.wrapinstance(long(_OpenMayaUI.MQtUtil.mainWindow()), _QtCore.QObject)
Hopefully, a colleague of mine Yves Boudreault investigated the issue and found a fix. The error resides in the sip code that is extracting address into a "unsigned long" instead of "unsigned long long". I.e.: siplib.c.in
/* * Wrap an instance. */ static PyObject *wrapInstance(PyObject *self, PyObject *args) { unsigned long addr; sipWrapperType *wt; if (PyArg_ParseTuple(args, "kO!:wrapinstance", &addr, &sipWrapperType_Type, &wt)) return sip_api_convert_from_type((void *)addr, wt->type, NULL); return NULL; }
and this is because Maya runs on x64 vs win32. The fix is easy, see below:
Fixed code for 64 bit ( unsigned long" -> "unsigned long long" and "kO!:wrapinstance" -> "KO!:wrapinstance" )
/* * Wrap an instance. */ static PyObject *wrapInstance(PyObject *self, PyObject *args) { unsigned long long addr; sipWrapperType *wt; if (PyArg_ParseTuple(args, "KO!:wrapinstance", &addr, &sipWrapperType_Type, &wt)) return sip_api_convert_from_type((void *)addr, wt->type, NULL); return NULL; }
The fix has been posted on the Riverbank's pyQt mailing list.
Comments