[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] sip.wrapinstance crashes when object address is larger than 32 bits.
From:       Yves Boudreault <Yves.Boudreault () autodesk ! com>
Date:       2014-01-29 17:05:56
Message-ID: 6F4271F68F954641BA3DA62EFE96AD3E1D7641B9 () 005-TK5MPN2-022 ! MGDADSK ! autodesk ! com
[Download RAW message or body]

Hi,
On a Windows 64 bit machine, when "long(_OpenMayaUI.MQtUtil.mainWindow())" gets \
larger than 32 bits there is a crash in _sip.wrapinstance. Sample python code that is \
crashing: 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)

The fix is simple; here is how I got around the issue. I just change ( unsigned long" \
-> "unsigned long long" and "kO!:wrapinstance" -> "KO!:wrapinstance" ) in \
"siplib.c.in" and recompiled.

/*
 * 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;
}
Please let me know if there is another workaround.
Yves


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:0in;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span \
style="font-size:10.5pt;line-height:115%;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#333333">Hi,<o:p></o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:10.5pt;line-height:115%;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#333333">On \
a Windows 64 bit machine, when &#8220;long(_OpenMayaUI.MQtUtil.mainWindow())&#8221; \
gets larger than 32 bits there is a crash in _sip.wrapinstance.&nbsp; \
<o:p></o:p></span></p> <div \
style="mso-element:para-border-div;border:none;border-bottom:solid windowtext \
1.0pt;padding:0in 0in 1.0pt 0in"> <p class="MsoNormal" \
style="border:none;padding:0in">Sample python code that is crashing:<o:p></o:p></p> \
</div> <p class="MsoNormal"><span \
style="font-size:10.5pt;line-height:115%;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#333333">import \
sip as _sip<br> import PyQt4.QtCore as _QtCore<br>
import PyQt4.QtGui as _QtGui<br>
import maya.OpenMayaUI as _OpenMayaUI<br>
<br>
mainWindow = _sip.wrapinstance(long(_OpenMayaUI.MQtUtil.mainWindow()), \
_QtCore.QObject)<o:p></o:p></span></p> <div \
style="mso-element:para-border-div;border:none;border-bottom:solid windowtext \
1.0pt;padding:0in 0in 1.0pt 0in"> <p class="MsoNormal" \
style="border:none;padding:0in"><o:p>&nbsp;</o:p></p> </div>
<p class="MsoNormal"><span \
style="font-size:10.5pt;line-height:115%;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#333333">The \
fix is simple; here is how I got around the issue. I just change ( unsigned \
long&quot; -&gt; &quot;unsigned long long&quot; and &quot;kO!:wrapinstance&quot; \
-&gt; &quot;KO!:wrapinstance&quot;  ) in &#8220;siplib.c.in&#8221; and \
recompiled.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.5pt;line-height:115%;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#333333"><br>
 /*<br>
&nbsp;* Wrap an instance.<br>
&nbsp;*/<br>
static PyObject *wrapInstance(PyObject *self, PyObject *args)<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;unsigned long long addr;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sipWrapperType *wt;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;if (PyArg_ParseTuple(args, &quot;KO!:wrapinstance&quot;, \
&amp;addr, &amp;sipWrapperType_Type, &amp;wt))<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return \
sip_api_convert_from_type((void *)addr, wt-&gt;type, NULL);<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;return NULL;<br>
}<o:p></o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:10.5pt;line-height:115%;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#333333">Please \
let me know if there is another workaround.<o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:10.5pt;line-height:115%;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#333333">Yves<o:p></o:p></span></p>
 <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--===============4159588947195333699==--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic