SIGABRT when setting QQmlListProperty

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

SIGABRT when setting QQmlListProperty

Cody Scott-2
I'm using PyQt5==5.7.1.

I'm trying to set a list property from QML. I'm using @pyqtProperty(QQmlListProperty)
I'm getting an error that TypeError: list element must be of type 'str', not 'NoneType' but they are strings in QML.

After that I get a SIGABRT.

Code and output here.

The gist and the attached file are the same.



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

setter_QQmlListProperty.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SIGABRT when setting QQmlListProperty

Phil Thompson-5
On 12 Jan 2017, at 9:05 pm, Cody Scott <[hidden email]> wrote:

>
> I'm using PyQt5==5.7.1.
>
> I'm trying to set a list property from QML. I'm using @pyqtProperty(QQmlListProperty)
> I'm getting an error that TypeError: list element must be of type 'str', not 'NoneType' but they are strings in QML.
>
> After that I get a SIGABRT.
>
> Code and output here.
> https://gist.github.com/Siecje/0a6cb1b49358f9373496bd8952bfd1fd
>
> The gist and the attached file are the same.

QQmlListProperty can only handle lists with elements that are sub-types of QObject.

I've improved the error checking.

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIGABRT when setting QQmlListProperty

Cody Scott-2
So what type should the @pyqtProperty have for lists of other types? For example a list of strings?

On Fri, Jan 13, 2017 at 6:53 AM, Phil Thompson <[hidden email]> wrote:
On 12 Jan 2017, at 9:05 pm, Cody Scott <[hidden email]> wrote:
>
> I'm using PyQt5==5.7.1.
>
> I'm trying to set a list property from QML. I'm using @pyqtProperty(QQmlListProperty)
> I'm getting an error that TypeError: list element must be of type 'str', not 'NoneType' but they are strings in QML.
>
> After that I get a SIGABRT.
>
> Code and output here.
> https://gist.github.com/Siecje/0a6cb1b49358f9373496bd8952bfd1fd
>
> The gist and the attached file are the same.

QQmlListProperty can only handle lists with elements that are sub-types of QObject.

I've improved the error checking.

Phil


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIGABRT when setting QQmlListProperty

Cody Scott-2
I'm using @pyqtProperty(QtCore.QVariant) for the list property and it works as long as I do .toVariant() in the setter.

One thing is that it calls the setter twice for each instance in this example. I believe it should only call each setter once. 




On Fri, Jan 13, 2017 at 9:04 AM, Cody Scott <[hidden email]> wrote:
So what type should the @pyqtProperty have for lists of other types? For example a list of strings?

On Fri, Jan 13, 2017 at 6:53 AM, Phil Thompson <[hidden email]> wrote:
On 12 Jan 2017, at 9:05 pm, Cody Scott <[hidden email]> wrote:
>
> I'm using PyQt5==5.7.1.
>
> I'm trying to set a list property from QML. I'm using @pyqtProperty(QQmlListProperty)
> I'm getting an error that TypeError: list element must be of type 'str', not 'NoneType' but they are strings in QML.
>
> After that I get a SIGABRT.
>
> Code and output here.
> https://gist.github.com/Siecje/0a6cb1b49358f9373496bd8952bfd1fd
>
> The gist and the attached file are the same.

QQmlListProperty can only handle lists with elements that are sub-types of QObject.

I've improved the error checking.

Phil



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

whySetterMultipleTimes.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SIGABRT when setting QQmlListProperty

Phil Thompson-5
On 13 Jan 2017, at 6:06 pm, Cody Scott <[hidden email]> wrote:
>
> I'm using @pyqtProperty(QtCore.QVariant) for the list property and it works as long as I do .toVariant() in the setter.
>
> One thing is that it calls the setter twice for each instance in this example. I believe it should only call each setter once.
>
> https://gist.github.com/Siecje/d1f2b270305762b4f73540c72adee6b8

If you comment in the test to see if the value has really changed then it seems to do as you expect.

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIGABRT when setting QQmlListProperty

Cody Scott-2
That's true but it seems like something that should not be happening.

On Fri, Jan 13, 2017 at 5:24 PM, Phil Thompson <[hidden email]> wrote:
On 13 Jan 2017, at 6:06 pm, Cody Scott <[hidden email]> wrote:
>
> I'm using @pyqtProperty(QtCore.QVariant) for the list property and it works as long as I do .toVariant() in the setter.
>
> One thing is that it calls the setter twice for each instance in this example. I believe it should only call each setter once.
>
> https://gist.github.com/Siecje/d1f2b270305762b4f73540c72adee6b8

If you comment in the test to see if the value has really changed then it seems to do as you expect.

Phil


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIGABRT when setting QQmlListProperty

Cody Scott-2
This was a Qt bug and has been fixed. https://bugreports.qt.io/browse/QTBUG-60427

And instead of a SIGABRT there is a nice error message!

Traceback (most recent call last):
  File "bug.py", line 15, in names
    return QtQml.QQmlListProperty(str, self, self._names)
TypeError: type argument must be a sub-type of QObject



On Fri, 13 Jan 2017 at 22:26, Cody Scott <[hidden email]> wrote:
That's true but it seems like something that should not be happening.

On Fri, Jan 13, 2017 at 5:24 PM, Phil Thompson <[hidden email]> wrote:
On 13 Jan 2017, at 6:06 pm, Cody Scott <[hidden email]> wrote:
>
> I'm using @pyqtProperty(QtCore.QVariant) for the list property and it works as long as I do .toVariant() in the setter.
>
> One thing is that it calls the setter twice for each instance in this example. I believe it should only call each setter once.
>
> https://gist.github.com/Siecje/d1f2b270305762b4f73540c72adee6b8

If you comment in the test to see if the value has really changed then it seems to do as you expect.

Phil


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt