QML File Manager App Suddenly Crashes
-
Hello everyone!
I am working on a dashboard app which consists of a file manager and some other components.FileManager is a component of my app which shows file system folders and files using a delegate from a C++ model.
The problem is when I enter a large directory e.g. one that contains +1000 files, my app crashes. I have tried different approcahes like subclassing
QAbstractListModelfor my file system model, usingGridViewfor displaying files, ... but none of them worked.I even cloned a file system viewer project from GitHub and compiled it and it worked. But when I linked it with my app using Qt Module API my app crashed again!
Here is the QML code of
FileManager:import QtQuick import QtQuick.Controls as C import axentra_ui Item { id: _root property var _fileManagerController: AxentraUi.fileManagerController Row { id: controls spacing: 10 FileManagerButton { id: backButton text: qsTr("Back") iconSource: "/icons/previous.svg" enabled: _fileManagerController.backEnabled onClicked: _fileManagerController.goBack() } FileManagerButton { id: nextButton text: qsTr("Forward") iconSource: "/icons/next.svg" enabled: _fileManagerController.forwardEnabled onClicked: _fileManagerController.goForward() } FileManagerButton { id: settings text: qsTr("Settings") iconSource: "/icons/settings.svg" onClicked: settingsPopup.open() } } Popup { id: settingsPopup x: (_root.width - width) / 2 y: (_root.height - height) / 2 width: 800 height: 500 C.ScrollView { anchors.fill: parent contentWidth: parent.width Column { spacing: 15 anchors.top: parent.top anchors.topMargin: 25 anchors.horizontalCenter: parent.horizontalCenter SettingsEntryCombo { name: qsTr("Default File Manager") model: [qsTr("KDE"), qsTr("gnome")] } SettingsEntry { name: qsTr("Default Save Location") } SettingsEntrySwitch { id: showHiddenFilesSwitch name: qsTr("Show Hidden Files") onCheckedChanged: _fileManagerController.showHiddenFiles = checked } SettingsEntrySwitch { id: confirmBeforeDeleteSwitch name: qsTr("Confirm Before Delete") } SettingsEntry { id: removableMediaButton name: qsTr("Removable Media") } SettingsEntry { id: storageOverviewButton name: qsTr("Storage Overview") } } } } C.ScrollView { anchors.fill: parent anchors.topMargin: controls.height + 30 contentWidth: width Grid { width: parent.width columns: width / 100 columnSpacing: (width - (columns * 100)) / columns component File : Item { id: file width: 100 height: 100 property alias name: _name.text property alias icon: _icon.source signal clicked Image { id: _icon anchors.horizontalCenter: parent.horizontalCenter sourceSize.width: 50 } C.Label { id: _name anchors.horizontalCenter: _icon.horizontalCenter anchors.top: _icon.bottom anchors.topMargin: 5 width: parent.width height: 50 font.pointSize: 11 horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap elide: Text.ElideRight } MouseArea { anchors.fill: parent onClicked: file.clicked() cursorShape: Qt.PointingHandCursor } } Repeater { id: dirs model: _fileManagerController.dirs File { name: modelData icon: "/icons/folder.png" onClicked: _fileManagerController.openDir(name) } } Repeater { id: files model: _fileManagerController.files File { name: modelData icon: "/icons/document.png" } } } } }Here is the error I get:
14:03:57: The command "/home/salirezag/Projects/axentra_ui/build/Desktop_Qt_6_10_1-Debug/appaxentra_ui" terminated abnormally.Anyone can help me solve this problem? I appreciate it!
-
run your application through a debugger, preferably with a debug build of Qt
-
@GrecKo It didn't help. Just a segmentation fault was thrown. Here is my
Maincomponent:import QtQuick import QtQuick.Layouts import QtQuick.Effects Window { width: 1280 height: 960 visible: true title: qsTr("Control Panel") ColumnLayout { id: tabBar anchors.margins: 10 anchors.left: parent.left anchors.top: parent.top MenuButton { id: networkButton text: qsTr("Network") iconSource: "/icons/network.svg" checked: true } MenuButton { id: fileManagerButton text: qsTr("File Manager") iconSource: "/icons/filemanager.svg" } MenuButton { id: displayButton text: qsTr("Display") iconSource: "/icons/display.svg" } MenuButton { id: aboutButton text: qsTr("About") iconSource: "/icons/about.svg" } } Rectangle { anchors.left: tabBar.right anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom anchors.leftMargin: 20 NetworkSettings { id: networkSettings anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 20 visible: networkButton.checked width: 600 model: [ { status: NetworkInterface.Connected, ip: "192.168.0.1", ipType: NetworkInterface.Ipv4, type: NetworkInterface.Wifi, name: "wlan0", txActive: true, rxActive: false }, { status: NetworkInterface.Connected, ip: "10.0.0.1", ipType: NetworkInterface.Ipv4, type: NetworkInterface.Wifi, name: "wlan0", txActive: true, rxActive: false } ] connectionState: NetworkSettings.Connected } FileManager { id: fileManager anchors.fill: parent anchors.margins: 20 visible: fileManagerButton.checked } DisplaySettings { id: displaySettings anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 20 visible: displayButton.checked width: 600 } About { id: about anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 20 visible: aboutButton.checked width: 600 } } }When I comment out
NetworkSettingsit works. It seems that this component is soaking up my memory. But I don't know why :).Here's my
NetworkSettings:import QtQuick import QtQuick.Controls as C import QtQuick.Layouts import control_panel ColumnLayout { id: _root property bool networkEnabled: networkToggle.checked property var model enum ConnectionState { Connected, Connecting, Error } property int connectionState property string error spacing: 10 RowLayout { Layout.fillWidth: true C.Label { text: qsTr("Networking") } C.Label { text: networkEnabled ? Qt.enumValueToString(NetworkSettings.ConnectionState, NetworkSettings.Connected) + (connectionState == NetworkSettings.Error ? ` (${error})` : "") : "" Layout.fillWidth: true } Switch { id: networkToggle } } Repeater { model: _root.model NetworkInterface { status: modelData.status ip: modelData.ip ipType: modelData.ipType type: modelData.type name: modelData.name txActive: modelData.txActive rxActive: modelData.rxActive } } } -
@GrecKo It didn't help. Just a segmentation fault was thrown. Here is my
Maincomponent:import QtQuick import QtQuick.Layouts import QtQuick.Effects Window { width: 1280 height: 960 visible: true title: qsTr("Control Panel") ColumnLayout { id: tabBar anchors.margins: 10 anchors.left: parent.left anchors.top: parent.top MenuButton { id: networkButton text: qsTr("Network") iconSource: "/icons/network.svg" checked: true } MenuButton { id: fileManagerButton text: qsTr("File Manager") iconSource: "/icons/filemanager.svg" } MenuButton { id: displayButton text: qsTr("Display") iconSource: "/icons/display.svg" } MenuButton { id: aboutButton text: qsTr("About") iconSource: "/icons/about.svg" } } Rectangle { anchors.left: tabBar.right anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom anchors.leftMargin: 20 NetworkSettings { id: networkSettings anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 20 visible: networkButton.checked width: 600 model: [ { status: NetworkInterface.Connected, ip: "192.168.0.1", ipType: NetworkInterface.Ipv4, type: NetworkInterface.Wifi, name: "wlan0", txActive: true, rxActive: false }, { status: NetworkInterface.Connected, ip: "10.0.0.1", ipType: NetworkInterface.Ipv4, type: NetworkInterface.Wifi, name: "wlan0", txActive: true, rxActive: false } ] connectionState: NetworkSettings.Connected } FileManager { id: fileManager anchors.fill: parent anchors.margins: 20 visible: fileManagerButton.checked } DisplaySettings { id: displaySettings anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 20 visible: displayButton.checked width: 600 } About { id: about anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 20 visible: aboutButton.checked width: 600 } } }When I comment out
NetworkSettingsit works. It seems that this component is soaking up my memory. But I don't know why :).Here's my
NetworkSettings:import QtQuick import QtQuick.Controls as C import QtQuick.Layouts import control_panel ColumnLayout { id: _root property bool networkEnabled: networkToggle.checked property var model enum ConnectionState { Connected, Connecting, Error } property int connectionState property string error spacing: 10 RowLayout { Layout.fillWidth: true C.Label { text: qsTr("Networking") } C.Label { text: networkEnabled ? Qt.enumValueToString(NetworkSettings.ConnectionState, NetworkSettings.Connected) + (connectionState == NetworkSettings.Error ? ` (${error})` : "") : "" Layout.fillWidth: true } Switch { id: networkToggle } } Repeater { model: _root.model NetworkInterface { status: modelData.status ip: modelData.ip ipType: modelData.ipType type: modelData.type name: modelData.name txActive: modelData.txActive rxActive: modelData.rxActive } } }@salirezag said in QML File Manager App Suddenly Crashes:
@GrecKo It didn't help. Just a segmentation fault was thrown.
You don't have any stacktrace?
@salirezag said in QML File Manager App Suddenly Crashes:
When I comment out NetworkSettings it works. It seems that this component is soaking up my memory. But I don't know why :).
Figure out why then. How many memory is used/free when your app crashes? Run it through a memory profiler.