QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem
-
Hi everyone,
I am on Windows11 x64, with Qt6.7.2 on Qt Creator version 14TITLE: QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem
APP DESCRIPTION:
I have a dialog window with a QTreeWidget which stores a list of Items is this format:
- column 0 contains file_path_names || column 1 contains the full_file_path
on the right side I have two line edit to display the full_path (and allowing user to change it) and the file_name. Beside the lines edit there are two buttons; one of these is "remove_btn". Clicking the button will clear the current lines edit, delete the item from the TreeWidget and also delete the path stored in a QList<QString> member variable for keeping track off the path removed or added.
problem and error description
Assuming three item (paths) are given and displayed in the QTreeWidget, and selecting the bottom one and deleting it, no problems occure
After deleting the second item, still no problem occure
(last item remained) deleting the last item, remove itself correctly from the TreeWidget but after few seconds the app crashs.
Question
Can the QTreeWidget stand without the WidgetItems? I have no clue why this is happening..
void Dialog::on_removePath_btn_clicked() { auto current_path = ui->fPath_le->text(); removePathFromTreeWdg(); // iterate and delete the item // corrisponding to the current path QMutableListIterator<QString> str_it(m_paths); while (str_it.hasNext()) { if (str_it.next() == current_path) { str_it.remove(); break; } } // emit signal emit pathRemoved(m_groupName, current_path); } void Dialog::removePathFromTreeWdg() { QTreeWidgetItem* currentItem = ui->left_wdg->currentItem(); if (!currentItem) return; QTreeWidgetItem* parent = currentItem->parent(); int index; if (parent) { index = parent->indexOfChild(ui->left_wdg->currentItem()); delete parent->takeChild(index); } else { index = ui->left_wdg->indexOfTopLevelItem(ui->left_wdg->currentItem()); delete ui->left_wdg->takeTopLevelItem(index); } }
-
@Andrea_Venturelli said in QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem:
after few seconds the app crashs
Then please run your app in debugger and post the stack trace after the crash
-
@jsulm
you need to help me about this request because yesterday I tryed to lunch the app in debug mode for the first time ever in my life, and i didn't get it :/What are the steps that i need to do, in order to collect the information you need ?
thanks in advance. -
I have an Hint; seems that, after removing successfully once of the three item, the QTreeWidget automatically select the previous index (if it is the first item, select the index after). When the last only remaining item is deleted i think the QTreeWidget is trying to set the previous index, but no indexex are available causing the program to crush
-
@Andrea_Venturelli said in QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem:
What are the steps that i need to do, in order to collect the information you need ?
Click at the button in the bottom right corner with a bug on it in Qtcreator.
When the app crashes you will have the stack trace at the bottom. -
@jsulm okay, when i compile and run the application normaly, the application starts and I can test it without problems.
Instead, trying to run it in the Debug Mode (the button in the bottom-corner) nothing appen and no window appear..Here some screenshots:
1show version 2show debug-file-directory 3set max-completions 1000 4complete set arch 5set breakpoint pending on 6set print elements 10000 7set index-cache on 8set unwindonsignal on 9set width 0 10set height 0 Setting up inferior... 11set substitute-path /Users/qt/work/qt C:/Qt/6.7.1/Src 12set substitute-path C:/work/build/qt5_workdir/w/s C:/Qt/6.7.1/Src 13set substitute-path Q:/qt5_workdir/w/s C:/Qt/6.7.1/Src 14set substitute-path c:/Users/qt/work/install C:/Qt/6.7.1/Src 15set substitute-path c:/users/qt/work/qt C:/Qt/6.7.1/Src # directory does not exist: /usr/src/debug/qt5base/src/corelib # directory does not exist: /usr/src/debug/qt5base/src/gui # directory does not exist: /usr/src/debug/qt5base/src/network 16python sys.path.insert(1, 'C:/Qt/Tools/QtCreator/share/qtcreator/debugger') 17python from gdbbridge import * 18python theDumper.loadDumpers({"token":18}) Debugging has failed. 19show version 20show debug-file-directory 21set max-completions 1000 22complete set arch 23set breakpoint pending on 24set print elements 10000 25set index-cache on 26set unwindonsignal on 27set width 0 28set height 0 Setting up inferior... 29set substitute-path /Users/qt/work/qt C:/Qt/6.7.1/Src 30set substitute-path C:/work/build/qt5_workdir/w/s C:/Qt/6.7.1/Src 31set substitute-path Q:/qt5_workdir/w/s C:/Qt/6.7.1/Src 32set substitute-path c:/Users/qt/work/install C:/Qt/6.7.1/Src 33set substitute-path c:/users/qt/work/qt C:/Qt/6.7.1/Src # directory does not exist: /usr/src/debug/qt5base/src/corelib # directory does not exist: /usr/src/debug/qt5base/src/gui # directory does not exist: /usr/src/debug/qt5base/src/network 34python sys.path.insert(1, 'C:/Qt/Tools/QtCreator/share/qtcreator/debugger') 35python from gdbbridge import * 36python theDumper.loadDumpers({"token":36}) Debugging has failed. 37show version 38show debug-file-directory 39set max-completions 1000 40complete set arch 41set breakpoint pending on 42set print elements 10000 43set index-cache on 44set unwindonsignal on 45set width 0 46set height 0 Setting up inferior... 47set substitute-path /Users/qt/work/qt C:/Qt/6.7.1/Src 48set substitute-path C:/work/build/qt5_workdir/w/s C:/Qt/6.7.1/Src 49set substitute-path Q:/qt5_workdir/w/s C:/Qt/6.7.1/Src 50set substitute-path c:/Users/qt/work/install C:/Qt/6.7.1/Src 51set substitute-path c:/users/qt/work/qt C:/Qt/6.7.1/Src # directory does not exist: /usr/src/debug/qt5base/src/corelib # directory does not exist: /usr/src/debug/qt5base/src/gui # directory does not exist: /usr/src/debug/qt5base/src/network 52python sys.path.insert(1, 'C:/Qt/Tools/QtCreator/share/qtcreator/debugger') 53python from gdbbridge import * 54python theDumper.loadDumpers({"token":54}) Debugging has failed. 55show version 56show debug-file-directory 57set max-completions 1000 58complete set arch 59set breakpoint pending on 60set print elements 10000 61set index-cache on 62set unwindonsignal on 63set width 0 64set height 0 Setting up inferior... 65set substitute-path /Users/qt/work/qt C:/Qt/6.7.1/Src 66set substitute-path C:/work/build/qt5_workdir/w/s C:/Qt/6.7.1/Src 67set substitute-path Q:/qt5_workdir/w/s C:/Qt/6.7.1/Src 68set substitute-path c:/Users/qt/work/install C:/Qt/6.7.1/Src 69set substitute-path c:/users/qt/work/qt C:/Qt/6.7.1/Src # directory does not exist: /usr/src/debug/qt5base/src/corelib # directory does not exist: /usr/src/debug/qt5base/src/gui # directory does not exist: /usr/src/debug/qt5base/src/network 70python sys.path.insert(1, 'C:/Qt/Tools/QtCreator/share/qtcreator/debugger') 71python from gdbbridge import * 72python theDumper.loadDumpers({"token":72}) Debugging has failed. 73show version 74show debug-file-directory 75set max-completions 1000 76complete set arch 77set breakpoint pending on 78set print elements 10000 79set index-cache on 80set unwindonsignal on 81set width 0 82set height 0 Setting up inferior... 83set substitute-path /Users/qt/work/qt C:/Qt/6.7.1/Src 84set substitute-path C:/work/build/qt5_workdir/w/s C:/Qt/6.7.1/Src 85set substitute-path Q:/qt5_workdir/w/s C:/Qt/6.7.1/Src 86set substitute-path c:/Users/qt/work/install C:/Qt/6.7.1/Src 87set substitute-path c:/users/qt/work/qt C:/Qt/6.7.1/Src # directory does not exist: /usr/src/debug/qt5base/src/corelib # directory does not exist: /usr/src/debug/qt5base/src/gui # directory does not exist: /usr/src/debug/qt5base/src/network 88python sys.path.insert(1, 'C:/Qt/Tools/QtCreator/share/qtcreator/debugger') 89python from gdbbridge import * 90python theDumper.loadDumpers({"token":90}) Debugging has failed. 91show version 92show debug-file-directory 93set max-completions 1000 94complete set arch 95set breakpoint pending on 96set print elements 10000 97set index-cache on 98set unwindonsignal on 99set width 0 100set height 0 Setting up inferior... 101set substitute-path /Users/qt/work/qt C:/Qt/6.7.1/Src 102set substitute-path C:/work/build/qt5_workdir/w/s C:/Qt/6.7.1/Src 103set substitute-path Q:/qt5_workdir/w/s C:/Qt/6.7.1/Src 104set substitute-path c:/Users/qt/work/install C:/Qt/6.7.1/Src 105set substitute-path c:/users/qt/work/qt C:/Qt/6.7.1/Src # directory does not exist: /usr/src/debug/qt5base/src/corelib # directory does not exist: /usr/src/debug/qt5base/src/gui # directory does not exist: /usr/src/debug/qt5base/src/network 106python sys.path.insert(1, 'C:/Qt/Tools/QtCreator/share/qtcreator/debugger') 107python from gdbbridge import * 108python theDumper.loadDumpers({"token":108}) Debugging has failed. d[GDB] UNEXPECTED GDB STDERR: error: unknown option: --tty=\\.\pipe\creator-11944-28798 derror: unknown option: -i dUse 'lldb.exe --help' for a complete list of options. d[GDB] GDB PROCESS FINISHED, status 0, exit code 1 (0x1) d[GDB] NOTE: ENGINE SETUP FAILED d[GDB] State changed from EngineSetupRequested(1) to EngineSetupFailed(2) <Debugging has failed. d[GDB] State changed from EngineSetupFailed(2) to DebuggerFinished(16)
-
@Andrea_Venturelli It's not clear to me what debugger you set in the Kit you're using? Seems to be lldb. With MinGW one is usually using GDB. The GDB debugger is provided as part of the MinGW setup from Qt Online Installer.
-
@jsulm let's see if this helps you a little bit more.
unfortunally i do not understand where I need to search for the informations needed to help you understand why my debugger fails to compile and run.
I'm open to suggestions or direction where to retrive this kind of helpfull information in order to simplify your life and not wasting so much of yours time.
-
@Andrea_Venturelli Please check in the Kit you're using what debugger is set there. It should be GDB from MinGW.
-
yes @jsulm, is GDB as illustrated in the code snippet some messages ago
this is taken from the "Global Debugger Log" panel , after running the Debug play button
and is clearly referring to GDB- GDB PROCESS FINISHED, status 0, exit code 1 (0x1)
- d[GDB] NOTE: ENGINE SETUP FAILED
d[GDB] UNEXPECTED GDB STDERR: error: unknown option: --tty=\\.\pipe\creator-11944-28798 derror: unknown option: -i dUse 'lldb.exe --help' for a complete list of options. d[GDB] GDB PROCESS FINISHED, status 0, exit code 1 (0x1) d[GDB] NOTE: ENGINE SETUP FAILED d[GDB] State changed from EngineSetupRequested(1) to EngineSetupFailed(2) <Debugging has failed. d[GDB] State changed from EngineSetupFailed(2) to DebuggerFinished(16)
-
@Andrea_Venturelli said in QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem:
dUse 'lldb.exe --help' for a complete list of options.
Why don't you simply check in the Kit which debugger is set?
-
how can i do that? it's not clear to me, where the informations of the debug type resides; a screenshot could be helpfull or even the path like so:
[Qt creator] >> Edit >> Preferences... >> Debugger .. and so on or
[Qt Maintenance Tool] >> Extencion >> ecc..because I have a little experience with Qt Creator, resulting in me, not knowing where to look for
-
@Andrea_Venturelli [Qt creator] >> Edit >> Preferences... >> Kits - then select the Kit you're using
-
this is what I use to create the projects (and using qMake to built):
-
@Andrea_Venturelli Please show ALL settings of that Kit (especially Qt version and debugger set).
-
Desktop Qt 6.7.1 llvm-mingw 64-bit
c++ compiler:
LLVM-MinGW 17.0.6 64-bit for c++
Debugger:
LLVM lldb 17.0.6 64-bit
Qt version:
Qt 6.7.1 llvm-mingw 64-bit
CMake Tool:
CMake 3.27.7 (Qt)
-
@Andrea_Venturelli Try with Qt for MinGW (not llvm-mingw).
Maybe QtCreator does not support lldb properly. -
It looks like the LLVM MInGW debugger has the wrong debugger type set. It should be
LLDB
and notGDB
.https://bugreports.qt.io/browse/QTBUG-123330 was supposed to be a thing of the past...
-
How should I change the current project KIT, transitioning from llvm-mingw to MinGW ??
I tryed it, from the preferences panel under: Edit >> Preferences... >> Kits
but I'm pretty sure that has no impact on the current project, instead will change the default Kit, the next time I'll create a new project.Exists such a way to change the Kit to the current running project or I'm forced to create a brand-new one and manually paste the code?
-
@Andrea_Venturelli said in QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem:
How should I change the current project KIT, transitioning from llvm-mingw to MinGW ??
On the right side in QtCreator "Projects".
From your screen-shots it looks like you already have a Kit for Qt MinGW.