Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem
Forum Updated to NodeBB v4.3 + New Features

QTreeWidget causes the app to crash after deleting the last QTreeWidgetItem

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 3 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Andrea_Venturelli

    @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:

    image.png

    f304fd43-51ed-4576-842c-b43f0c986ab0-image.png

    021d4432-5db8-4214-8230-24eb2fb7c1a6-image.png

    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)
    
    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #7

    @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.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • A Offline
      A Offline
      Andrea_Venturelli
      wrote on last edited by
      #8

      @jsulm let's see if this helps you a little bit more.

      7551d7e9-6840-4fee-8127-a59a5602b989-image.png

      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.

      jsulmJ 1 Reply Last reply
      0
      • A Andrea_Venturelli

        @jsulm let's see if this helps you a little bit more.

        7551d7e9-6840-4fee-8127-a59a5602b989-image.png

        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.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #9

        @Andrea_Venturelli Please check in the Kit you're using what debugger is set there. It should be GDB from MinGW.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Andrea_Venturelli
          wrote on last edited by Andrea_Venturelli
          #10

          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)
          
          jsulmJ 1 Reply Last reply
          0
          • A Andrea_Venturelli

            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)
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #11

            @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?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Andrea_Venturelli
              wrote on last edited by
              #12

              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

              jsulmJ 1 Reply Last reply
              0
              • A Andrea_Venturelli

                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

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #13

                @Andrea_Venturelli [Qt creator] >> Edit >> Preferences... >> Kits - then select the Kit you're using

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Andrea_Venturelli
                  wrote on last edited by
                  #14

                  this is what I use to create the projects (and using qMake to built):

                  2afcf80d-aff5-4617-b083-7595a9fc08d9-image.png

                  fca12174-061d-4777-b7bb-e4587d46b207-image.png

                  jsulmJ 1 Reply Last reply
                  0
                  • A Andrea_Venturelli

                    this is what I use to create the projects (and using qMake to built):

                    2afcf80d-aff5-4617-b083-7595a9fc08d9-image.png

                    fca12174-061d-4777-b7bb-e4587d46b207-image.png

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #15

                    @Andrea_Venturelli Please show ALL settings of that Kit (especially Qt version and debugger set).

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Andrea_Venturelli
                      wrote on last edited by
                      #16

                      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)

                      4e8e562b-d582-404d-8525-9e23544ff8aa-image.png

                      jsulmJ 1 Reply Last reply
                      0
                      • A Andrea_Venturelli

                        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)

                        4e8e562b-d582-404d-8525-9e23544ff8aa-image.png

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #17

                        @Andrea_Venturelli Try with Qt for MinGW (not llvm-mingw).
                        Maybe QtCreator does not support lldb properly.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • cristian-adamC Offline
                          cristian-adamC Offline
                          cristian-adam
                          wrote on last edited by cristian-adam
                          #18

                          It looks like the LLVM MInGW debugger has the wrong debugger type set. It should be LLDB and not GDB.

                          https://bugreports.qt.io/browse/QTBUG-123330 was supposed to be a thing of the past...

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            Andrea_Venturelli
                            wrote on last edited by
                            #19

                            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?

                            jsulmJ 1 Reply Last reply
                            0
                            • A Andrea_Venturelli

                              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?

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #20

                              @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.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                Andrea_Venturelli
                                wrote on last edited by
                                #21

                                okay, finally we did it!
                                for the other reader who might encounter this problem with the debugger, the solution is:

                                1. on the left panel (where it is "Welcome", "Edit", "Design") there is "Projects"
                                2. open projects and under "Built & Run" you have all the kit available
                                3. I switched from Desktop Qt 6.7.1 llvm-mingw 64-bit to Desktop Qt 6.7.1 MinGW 64-bit
                                4. I pressed the "run" button and compile fine.
                                5. after I Run the normal "Debug play button" at the bottom left cornern and now is working

                                009e87f9-5bf1-4471-b513-4f63b7bd230a-image.png

                                now we can go back to the main issues where this discussion started

                                1 Reply Last reply
                                1
                                • A Offline
                                  A Offline
                                  Andrea_Venturelli
                                  wrote on last edited by
                                  #22

                                  this is the error I get after deleting the last item in the QTreeWidget:

                                  790d0649-97c5-47ae-81db-d4585de35e97-image.png

                                  here the call stack:
                                  fd4c28d6-fa62-47b4-b237-68a08deab34d-image.png

                                  I also found out where was the problem, other then I'm a big chicken ;)

                                  SOLUTION

                                  I had the QTreeWidget::ItemChanged signal, connected to one of my custom slots where i automatically update the values inside the LineEdits. But I ignored that, even when the last item is deleted, the QTreeWidget calls the "ItemChanged" signal.

                                  adding a check if the, before trying to retrive information from an empty QTreeWidgetItem solved the problem

                                  void Dialog::on_treeWidgetItemChanged()
                                  {
                                      // check control
                                      if (m_paths.count())
                                      {
                                          auto current_itm = ui->left_wdg->currentItem();
                                  
                                          // update the lineEdit' values
                                          ui->fn_le->setText(current_itm->text(0));           // THIS WAS THE CAUSE OF THE ERROR
                                          ui->fPath_le->setText(current_itm->text(1));
                                      }
                                  }
                                  
                                  1 Reply Last reply
                                  1
                                  • A Andrea_Venturelli has marked this topic as solved on

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved