[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] [sip] some low level issues with meta enum and flags
From: Denis Rouzaud <denis.rouzaud () gmail ! com>
Date: 2018-05-25 15:49:58
Message-ID: CAMtsY+aua8C8ahfrTOAkJ1Sco_24ynZz29Y5xu0x=C2sD-gx3A () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Phil,
Le ven. 25 mai 2018 Ã 10:26, Phil Thompson <phil@riverbankcomputing.com> a
écrit :
> On 18 May 2018, at 4:06 pm, Denis Rouzaud <denis.rouzaud@gmail.com> wrote:
> >
> > Hi list, hi Phil,
> >
> > I have been playing a bit with meta enum and I encountered two issues:
> >
> > 1. If you copy the meta enum object, you get a seg fault.
> > For instance, doing:
> > idx = baseClass.staticMetaObject.indexOfEnumerator(enumClass.__name__)
> > meta_enum = baseClass.staticMetaObject.enumerator(idx)
> >
> > And then do meta_enum_2 = meta_enum, you'll get a seg fault when trying
> to use it (calling any method, while sip.dump still seems to return valid
> output).
> >
> > This is not a huge deal, but it can lead to further issue: if you have a
> method where the meta_enum is provided as argument and get copied there.
> > For instance, we have a method with some MethodCode:
> > QgsSettings::value( const QString &key, const QVariant &defaultValue =
> QVariant() )
> > While providing the meta enum as default value, if I try to access it
> later, I do get a seg fault too.
>
> I need a short complete script that demonstrates the problem.
>
I am failing at doing a minimal example.
The issue occurs when calling this QgsSettings::value method with
following code:
SIP_PYOBJECT value( const QString &key, const QVariant
&defaultValue = QVariant(),
SIP_PYOBJECT type = 0,
QgsSettings::Section section =
QgsSettings::NoSection ) const / ReleaseGIL /;
% MethodCode
typedef PyObject *( *pyqt5_from_qvariant_by_type )( QVariant
&value, PyObject *type );
QVariant value;
// QSettings has an internal mutex so release the GIL to avoid the
possibility of deadlocks.
Py_BEGIN_ALLOW_THREADS
value = sipCpp->value( *a0, *a1, a3 );
Py_END_ALLOW_THREADS
pyqt5_from_qvariant_by_type f = ( pyqt5_from_qvariant_by_type )
sipImportSymbol( "pyqt5_from_qvariant_by_type" );
sipRes = f( value, a2 );
sipIsErr = !sipRes;
% End
No idea what is the issue, but it's no big deal.
> > 2. It seems that flags types are not added to the module itself but to
> the parant package.
> > In other words, __qualname__ returns the same than __name__
> > Which gives troubles at retrieving information.
> > Can this be fixed?
>
> Should be fixed in tonight's SIP snapshot.
>
awesome, thanks!
>
> Phil
[Attachment #5 (text/html)]
<div dir="ltr">Hi Phil,<div><br><div class="gmail_quote"><div dir="ltr">Le ven. 25 \
mai 2018 Ã 10:26, Phil Thompson <<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>> a \
écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">On 18 May 2018, at 4:06 pm, Denis \
Rouzaud <<a href="mailto:denis.rouzaud@gmail.com" \
target="_blank">denis.rouzaud@gmail.com</a>> wrote:<br> > <br>
> Hi list, hi Phil,<br>
> <br>
> I have been playing a bit with meta enum and I encountered two issues:<br>
> <br>
> 1. If you copy the meta enum object, you get a seg fault.<br>
> For instance, doing:<br>
> idx = baseClass.staticMetaObject.indexOfEnumerator(enumClass.__name__)<br>
> meta_enum = baseClass.staticMetaObject.enumerator(idx)<br>
> <br>
> And then do meta_enum_2 = meta_enum, you'll get a seg fault when trying to \
use it (calling any method, while sip.dump still seems to return valid output).<br> \
> <br> > This is not a huge deal, but it can lead to further issue: if you have \
a method where the meta_enum is provided as argument and get copied there.<br> > \
For instance, we have a method with some MethodCode:<br> > QgsSettings::value( \
const QString &key, const QVariant &defaultValue = QVariant() )<br> > \
While providing the meta enum as default value, if I try to access it later, I do get \
a seg fault too.<br> <br>
I need a short complete script that demonstrates the \
problem.<br></blockquote><div><br></div><div>I am failing at doing a minimal \
example.</div><div>The issue occurs when calling this QgsSettings::value method \
with following code:</div><div><br></div><div><pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>SIP_PYOBJECT<span style="color:rgb(192,192,192)"> </span>value(<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> \
</span>QString<span style="color:rgb(192,192,192)"> </span>&key,<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> \
</span>QVariant<span style="color:rgb(192,192,192)"> </span>&defaultValue<span \
style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> \
</span>QVariant(),</pre> <pre style="margin-top:0px;margin-bottom:0px"><span \
style="color:rgb(192,192,192)"> </span>SIP_PYOBJECT<span \
style="color:rgb(192,192,192)"> </span>type<span style="color:rgb(192,192,192)"> \
</span>=<span style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,0,128)">0</span>,</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>QgsSettings::Section<span style="color:rgb(192,192,192)"> </span>section<span \
style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> \
</span>QgsSettings::NoSection<span style="color:rgb(192,192,192)"> </span>)<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> \
</span>/<span style="color:rgb(192,192,192)"> </span>ReleaseGIL<span \
style="color:rgb(192,192,192)"> </span>/;</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>%<span style="color:rgb(192,192,192)"> </span>MethodCode</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,128,0)">typedef</span><span \
style="color:rgb(192,192,192)"> </span>PyObject<span style="color:rgb(192,192,192)"> \
</span>*(<span style="color:rgb(192,192,192)"> \
</span>*pyqt5_from_qvariant_by_type<span style="color:rgb(192,192,192)"> \
</span>)(<span style="color:rgb(192,192,192)"> </span>QVariant<span \
style="color:rgb(192,192,192)"> </span>&value,<span \
style="color:rgb(192,192,192)"> </span>PyObject<span style="color:rgb(192,192,192)"> \
</span>*type<span style="color:rgb(192,192,192)"> </span>);</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>QVariant<span style="color:rgb(192,192,192)"> </span>value;</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><br></pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">//</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">QSettings</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">has</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">an</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">internal</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">mutex</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">so</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">release</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">the</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">GIL</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">to</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">avoid</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">the</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">possibility</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(0,128,0)">of</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">deadlocks.</span></pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>Py_BEGIN_ALLOW_THREADS</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>value<span style="color:rgb(192,192,192)"> </span>=<span \
style="color:rgb(192,192,192)"> </span>sipCpp->value(<span \
style="color:rgb(192,192,192)"> </span>*a0,<span style="color:rgb(192,192,192)"> \
</span>*a1,<span style="color:rgb(192,192,192)"> </span>a3<span \
style="color:rgb(192,192,192)"> </span>);</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>Py_END_ALLOW_THREADS</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><br></pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>pyqt5_from_qvariant_by_type<span style="color:rgb(192,192,192)"> </span>f<span \
style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> \
</span>(<span style="color:rgb(192,192,192)"> </span>pyqt5_from_qvariant_by_type<span \
style="color:rgb(192,192,192)"> </span>)<span style="color:rgb(192,192,192)"> \
</span>sipImportSymbol(<span style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(0,128,0)">"pyqt5_from_qvariant_by_type"</span><span \
style="color:rgb(192,192,192)"> </span>);</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>sipRes<span style="color:rgb(192,192,192)"> </span>=<span \
style="color:rgb(192,192,192)"> </span>f(<span style="color:rgb(192,192,192)"> \
</span>value,<span style="color:rgb(192,192,192)"> </span>a2<span \
style="color:rgb(192,192,192)"> </span>);</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><br></pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>sipIsErr<span style="color:rgb(192,192,192)"> </span>=<span \
style="color:rgb(192,192,192)"> </span>!sipRes;</pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span>%<span style="color:rgb(192,192,192)"> \
</span>End</pre></div><div><br></div><div>No idea what is the issue, but it's no \
big deal.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">> 2. It seems that flags types \
are not added to the module itself but to the parant package.<br> > In other \
words, __qualname__ returns the same than __name__<br> > Which gives troubles at \
retrieving information.<br> > Can this be fixed?<br>
<br>
Should be fixed in tonight's SIP \
snapshot.<br></blockquote><div><br></div><div>awesome, thanks! </div><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <br>
Phil</blockquote></div></div></div>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic