[PyQt] [sip] some low level issues with meta enum and flags

Denis Rouzaud denis.rouzaud at gmail.com
Fri May 25 16:49:58 BST 2018


Hi Phil,

Le ven. 25 mai 2018 à 10:26, Phil Thompson <phil at riverbankcomputing.com> a
écrit :

> On 18 May 2018, at 4:06 pm, Denis Rouzaud <denis.rouzaud at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180525/455f3f51/attachment-0001.html>


More information about the PyQt mailing list