QChart addSeries Crash Problem
-
Hello,
I have a "not so small" Qt project, which I am using some QCharts also. It is running well on Windows. But in Ubuntu , it crashes while adding a QLineSeries to a Qt chart.
To simplify the problem, I replaced everything from my main() with simple line chart example code of QT. Again it crashes. Here is code from main, I dont call anything from my project:
int main(int argc,char *argv[]) { QApplication a(argc,argv); //![1] QLineSeries *series = new QLineSeries(); //![1] //![2] series->append(0,6); series->append(2,4); series->append(3,8); series->append(7,4); series->append(10,5); *series << QPointF(11,1) << QPointF(13,3) << QPointF(17,6) << QPointF(18,3) << QPointF(20,2); //![2] //![3] QChart *chart = new QChart(); chart->setEnabled(false); chart->legend()->hide(); series->setVisible(false); chart->addSeries(series); chart->createDefaultAxes(); chart->setTitle("Simple line chart example"); //![3] //![4] QChartView *chartView = new QChartView(chart); chartView->setRenderHint(QPainter::Antialiasing); //![4] //![5] QMainWindow window; window.setCentralWidget(chartView); window.resize(400,300); window.show(); //![5] return a.exec(); } //mainXIt crashes at line
chart->addSeries(series);The call stack with Qt source lines:
1 ??
2 QObjectPrivate::connectImpl qobject.cpp 5276 0x7ffff5bb77da
3 QObject::connectImpl qobject.cpp 5188 0x7ffff5bb7acd
4 QObject::connect<void (XYChart:: *)(QPointF const&), void (QXYSeries:: *)(QPointF const&)> move.h 101 0x7ffff772fb33
5 XYChart::XYChart xychart.cpp 32 0x7ffff772fb33
6 LineChartItem::LineChartItem linechartitem.cpp 27 0x7ffff775a884
7 QLineSeriesPrivate::initializeGraphics qlineseries.cpp 142 0x7ffff775ccef
8 ChartPresenter::handleSeriesAdded chartpresenter.cpp 132 0x7ffff76f0147
9 doActivate<false> qobject.cpp 4098 0x7ffff5bc1bd0
10 QMetaObject::activate qobject.cpp 4146 0x7ffff5bb98f0
11 ChartDataSet::seriesAdded moc_chartdataset_p.cpp 243 0x7ffff76e9222
12 main main_start.cpp 89 0x55555590615eOn crash, the debugger shows line at s->connectNotify(method); in qobject.cpp as seen above callstack.
QMetaMethod method = QMetaObjectPrivate::signal(senderMetaObject, signal_index); Q_ASSERT(method.isValid()); s->connectNotify(method);Project Info:
Project MESSAGE: CONFIG: lex yacc exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin file_copies qmake_use qt warn_on link_prl incremental shared plugin_manifest linux unix posix gcc qml_debug c++17 sdk_no_version_check console debug warn_on
Project MESSAGE: QT: core gui core gui serialbus charts datavisualization printsupport xml widgets
Project MESSAGE: QT_ARCH: x86_64
QT version 6.6.3This crash only occurs in ubuntu, not in windows. 3D maps are working fine. If I create a new basic project with the above simple main, again it runs perfect.
Only my simple static initializations are running in the above code since I dont call any function of my project from main().
Are there any other static inializations form QT that can cause this problem?Thanks a lot for you help....
Yasin -
Hi and welcome to devnet,
Testing on macOS with both 6.6.3 and 6.7.0, I could not get your reproducer to crash.
-
I have the same problem. I have already removed everything, leaving only an example from the documentation. On Fedora 41 Qt 6.8.0 it crashes every time, on Windows Qt 6.6.2 it crashes sometimes.
Вот пример конструктора виджета, больше ничего не вызывается:
QVBoxLayout * pVMainLayout = new QVBoxLayout; this->setLayout(pVMainLayout); m_pSeries = new QBarSeries(); m_pChart = new QChart(); m_pChart->addSeries(m_pSeries); m_pChart->setTitle("Title"); m_pChart->setAnimationOptions(QChart::SeriesAnimations); m_pAxisX = new QBarCategoryAxis(); m_pChart->addAxis(m_pAxisX, Qt::AlignBottom); m_pSeries->attachAxis(m_pAxisX); m_pAxisY = new QValueAxis(); m_pChart->addAxis(m_pAxisY, Qt::AlignLeft); m_pSeries->attachAxis(m_pAxisY); m_pChart->legend()->setVisible(true); m_pChart->legend()->setAlignment(Qt::AlignBottom); m_pChartView = new QChartView(m_pChart); m_pChartView->setRenderHint(QPainter::Antialiasing); pVMainLayout->addWidget(m_pChartView); m_pBarSet = new QBarSet("Test"); -
I have the same problem. I have already removed everything, leaving only an example from the documentation. On Fedora 41 Qt 6.8.0 it crashes every time, on Windows Qt 6.6.2 it crashes sometimes.
Вот пример конструктора виджета, больше ничего не вызывается:
QVBoxLayout * pVMainLayout = new QVBoxLayout; this->setLayout(pVMainLayout); m_pSeries = new QBarSeries(); m_pChart = new QChart(); m_pChart->addSeries(m_pSeries); m_pChart->setTitle("Title"); m_pChart->setAnimationOptions(QChart::SeriesAnimations); m_pAxisX = new QBarCategoryAxis(); m_pChart->addAxis(m_pAxisX, Qt::AlignBottom); m_pSeries->attachAxis(m_pAxisX); m_pAxisY = new QValueAxis(); m_pChart->addAxis(m_pAxisY, Qt::AlignLeft); m_pSeries->attachAxis(m_pAxisY); m_pChart->legend()->setVisible(true); m_pChart->legend()->setAlignment(Qt::AlignBottom); m_pChartView = new QChartView(m_pChart); m_pChartView->setRenderHint(QPainter::Antialiasing); pVMainLayout->addWidget(m_pChartView); m_pBarSet = new QBarSet("Test");