Solved Application exits on second call to FileDialog.open()
-
My main.qml defines an instance of FileDialog called "fileDialog". The FileDialog is displayed properly the first time fileDialog.open() is invoked. However the next time fileDialog.open() is invoked, the application exits. It does NOT core dump. I see this behavior whether or not I actually select a file, or choose "Cancel". My main.qml also defines a MessageDialog called "quitDialog", which can be invoked multiple times with no problem. Why does my application exit the second time fileDialog.open() is invoked? I am running Qt 5.14.2 on Ubuntu 18.04.4.
Here's main.qml:
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Dialogs 1.1 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") menuBar: MenuBar { Menu { title: "File" Action { text: "Open grid" ; onTriggered: { console.log("show file dialog") fileDialog.open()} } Action { text: "Exit" ; onTriggered: { console.log("exit"); quitDialog.open() } } } } FileDialog { id: fileDialog title: "Open file" nameFilters: ["Grid files (*.grd)"] onAccepted: { console.log("accepted " + fileUrl); } } MessageDialog { id: quitDialog title: "Quit?" icon: StandardIcon.Question text: "Quit application?" standardButtons: StandardButton.Yes | StandardButton.No Component.onCompleted: visible = false onYes: Qt.quit(0) onNo: console.log("did not quit") } }
My main.cpp is also very simple, and was auto-generated with qtcreator:
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
Thanks!
-
Solved: my application generated this error message on exit:
relocation error: /home/oreilly/Qt5.14.2/5.14.2/gcc_64/plugins/platformthemes/libqgtk3.so: symbol _ZdlPvm version Qt_5 not defined in file libQt5Core.so.5 with link time referenceThis message indicates that the application was compiled and linked with different flags that compiled the Qt5.14.2 libraries. I've recompiled the libraries, and now can call FileDialog.open() multiple times without a problem.