Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
None
-
5.12.0, 5.13.0, 5.13.1
-
None
Description
I have a QML PySide2 application that has a custom ChartView containing a PieSeries. The application starts and runs as expected. However, the program will occassionally crash when exiting (maybe 50% of the time). This crash has been noted on several versions of Windows and on the latest version of macOS. If I swap the PieSeries for another type like a LineSeries, I cannot reproduce the crash which leads me to believe there is an issue with the destruction of a PieSeries object. I can also reproduce this bug with the following types: BoxPlotSeries, StackedBarSeries, ScatterSeries, and BarSeries.
Here is a minimally reproducible example (I have attached it too):
main.py:
import sys from PySide2.QtWidgets import QApplication from PySide2.QtCore import QUrl from PySide2.QtQml import QQmlApplicationEngine, qmlRegisterType from custom_view import CustomView import qml_rc # noqa: F401 if __name__ == "__main__": app = QApplication(sys.argv) qmlRegisterType(CustomView, "CustomView", 1, 0, "CustomView") engine = QQmlApplicationEngine() engine.load(QUrl("qrc:/main.qml")) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec_())
main.qml:
import QtQuick 2.13 import QtQuick.Controls 2.13 ApplicationWindow { visible: true CustomView { anchors.fill: parent } }
custom_view.py:
from PySide2.QtQuick import QQuickItem class CustomView(QQuickItem): def __init__(self, parent=None) -> None: super().__init__(parent)
CustomView.qml:
import QtCharts 2.13 import QtQuick 2.13 import CustomView 1.0 CustomView { ChartView { anchors.fill: parent antialiasing: true animationOptions: ChartView.AllAnimations legend.visible: false // Replacing this PieSeries with another type of series works fine. PieSeries { id: pieSeries PieSlice { label: "eaten"; value: 94.9 } PieSlice { label: "not yet eaten"; value: 5.1 } } } }
qml.qrc:
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>CustomView.qml</file>
</qresource>
</RCC>
I run my program by doing the following:
pipenv install pipenv run pyside2-rcc -o qml_rc.py qml.qrc pipenv run python main.py
Closing the application will sometimes result in the following error in my console:
[1] 30219 segmentation fault pipenv run python main.py
Here are the first few lines of the stack trace:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 QtQml 0x00000001102e8dfb 0x1100f4000 + 2051579 1 QtQml 0x00000001102cc339 QQmlData::destroyed(QObject*) + 441 2 QtCore 0x000000010fd0e173 QObject::~QObject() + 291 3 libqtchartsqml2.dylib 0x000000011778f158 0x117771000 + 123224 4 QtQml 0x000000011010d5be QV4::MemoryManager::sweep(bool, void (*)(char const*)) + 318 5 QtQml 0x0000000110112eb1 QV4::MemoryManager::~MemoryManager() + 65 6 QtQml 0x0000000110297b74 QV4::ExecutionEngine::~ExecutionEngine() + 212 7 QtQml 0x00000001101a0437 QJSEngine::~QJSEngine() + 103 8 QtQml 0x00000001102cd632 QQmlEngine::~QQmlEngine() + 354 9 QtQml.abi3.so 0x000000011154b087 QQmlApplicationEngineWrapper::~QQmlApplicationEngineWrapper() + 55
Please see my two attachments containing the full stack trace, and a sample program to reproduce the bug.