I have a QML application with binding (via properties, Q_INVOKABLE , etc.) in C ++ code. I can run a QML application without most of the C ++ platform using qmlscene , and there are no obvious problems (other than the missing data and functions that should be provided by C ++).
However, when I create and deploy the code, I get segfault inside the Qt framework during the call to QQmlApplicationEngine::load() .
I created a simplified "dummy" application that causes the same problem.
C ++ application:
#include <QGuiApplication> #include <QQmlApplicationEngine> #include "SigCatcher.hpp" // Proprietary code int main( int argc, char *argv[]) { SigCatcher sig_catcher; // Just catches signals & prints stacktrace QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load( QUrl(QStringLiteral("qrc:/main.qml"))); return 0; }
Note that without SigCather I still get segfault, I just don't get the stack trace. Therefore, this example is reproduced if you comment out the import and SigCatcher declaration.
main.qml :
import QtQuick 2.5 import QtQuick.Controls 1.3 import QtCharts 2.0 ApplicationWindow { id: winRoot visible: true width: 1024 - 24 height: 768 - 80 minimumWidth: width minimumHeight: height maximumHeight: minimumHeight maximumWidth: minimumWidth ChartView { id: sparkline anchors.top: parent.top anchors.right: parent.right anchors.left: parent.left } }
There is almost nothing here, which leads me to believe that the ChartView type ChartView may have an error.
What could be? I donβt even know how to debug this; as far as I know, there is not even a way to use console.log during engine::load() before calling QGuiApplication::exec() .
EDIT: It was qmlscene that the application works correctly with qmlscene (which I did not know about when I first wrote the question).
EDIT 2: Replaced previous example, consisting of carefully selected fragments taken from proprietary code, with a complete generic example that shows the same problem (and has a slightly shorter glass).
Platform Information: Qt 5.5.1 runs on 64-bit Debian 8; my application compiled with GCC 5.1, but I see the same error with 4.9.2 and the preliminary version of Clang 3.7.0, which now is about 6 months old. I also tried using Qt 5.4.0 (which requires importing QtQuick 2.4 instead of 2.5 ).
Stacktrace:
../obj/X64_ATOM/debug/GUI/AucLocalGui2(_ZN22TracePrinterImpl_Linux16Print_stackTraceEv+0x42)[0x401e54] ../obj/X64_ATOM/debug/GUI/AucLocalGui2(_ZN12TracePrinter16Print_stackTraceEv+0x9)[0x401e7d] ../obj/X64_ATOM/debug/GUI/AucLocalGui2(_ZN20SigCatcherImpl_Linux15OnCatch_signal_Ei+0x68)[0x4022c6] /lib/x86_64-linux-gnu/libc.so.6(+0x35180)[0x7fe0a2234180] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Widgets.so.5(_ZN18QWidgetTextControl14setCursorWidthEi+0x55)[0x7fe0a527fb15] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Widgets.so.5(_ZN18QWidgetTextControlC1EP7QObject+0x5d)[0x7fe0a527fced] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Widgets.so.5(+0x443047)[0x7fe0a53a6047] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Widgets.so.5(_ZNK17QGraphicsTextItem8documentEv+0xd)[0x7fe0a53a633d] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/../../lib/libQt5Charts.so.2(+0x63821)[0x7fe098d74821] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/../../lib/libQt5Charts.so.2(+0x56cd3)[0x7fe098d67cd3] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/../../lib/libQt5Charts.so.2(+0x5727d)[0x7fe098d6827d] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/../../lib/libQt5Charts.so.2(+0x597d6)[0x7fe098d6a7d6] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/../../lib/libQt5Charts.so.2(+0x5bb7c)[0x7fe098d6cb7c] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/../../lib/libQt5Charts.so.2(+0x5fb8f)[0x7fe098d70b8f] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/libqtchartsqml2.so(+0x2f044)[0x7fe099072044] /opt/Qt/5.5.1/5.5/gcc_64/qml/QtCharts/libqtchartsqml2.so(+0x16680)[0x7fe099059680] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(_ZNK8QQmlType6createEv+0x3b)[0x7fe0a436e07b] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(+0x2cf472)[0x7fe0a43cf472] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(+0x2cc85d)[0x7fe0a43cc85d] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(+0x2cd45e)[0x7fe0a43cd45e] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(+0x2cde8e)[0x7fe0a43cde8e] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(+0x2cea8b)[0x7fe0a43cea8b] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(+0x2cfcef)[0x7fe0a43cfcef] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(_ZN20QQmlComponentPrivate11beginCreateEP15QQmlContextData+0x145)[0x7fe0a43592e5] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(_ZN13QQmlComponent6createEP11QQmlContext+0x68)[0x7fe0a4359728] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(_ZN28QQmlApplicationEnginePrivate13_q_finishLoadEP7QObject+0x262)[0x7fe0a43c0de2] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(_ZN28QQmlApplicationEnginePrivate9startLoadERK4QUrlRK10QByteArrayb+0xd2)[0x7fe0a43c1082] /opt/Qt/5.5.1/5.5/gcc_64/lib/libQt5Qml.so.5(_ZN21QQmlApplicationEngine4loadERK4QUrl+0x1d)[0x7fe0a43c10bd] ../obj/X64_ATOM/debug/GUI/AucLocalGui2(main+0x84)[0x401ae4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fe0a2220b45] ../obj/X64_ATOM/debug/GUI/AucLocalGui2[0x401959]