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. How do I delete the current QTreeWidget element correctly?
Forum Updated to NodeBB v4.3 + New Features

How do I delete the current QTreeWidget element correctly?

Scheduled Pinned Locked Moved Solved General and Desktop
33 Posts 4 Posters 4.6k 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.
  • H Helg1980

    Yes, I work in QtCreator.
    Here is my Application Output:

    18:31:38: Starting /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/cine_encoder ...
    18:31:53: The program has unexpectedly finished.
    18:31:53: The process was ended forcefully.
    18:31:53: /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/cine_encoder crashed.
    
    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #19

    @Helg1980
    OK, I don't know what you are doing, and what your program is doing.

    It is time now to use the debugger to put a breakpoint in your program, and step through offending code. Besides, I don't know how you are getting a "crashed" without the debugger catching it and showing you a stack trace back to the faulting line. If you are not familiar with using the debugger it's time you were, as you can resolve these issues very simply by using it!

    1 Reply Last reply
    0
    • H Helg1980

      Yes, I work in QtCreator.
      Here is my Application Output:

      18:31:38: Starting /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/cine_encoder ...
      18:31:53: The program has unexpectedly finished.
      18:31:53: The process was ended forcefully.
      18:31:53: /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/cine_encoder crashed.
      
      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #20

      @Helg1980
      Start the debugger. If you have a debugger in the background it will tell you where the assertion occurred.

      Q_ASSERT and Q_ASSUME are used to test implicit assumptions you make in your code.

      Looking at the sources QTreeWidget it looked like item->parent() for a top level item would return the invisible root item. I tested this implicit assumption with Q_ASSERT and it turns out I was wrong (but at least we know why)

      void SelectPreset::on_actionRemove_preset_clicked()  // Remove preset
      {
          QTreeWidgetItem *item = ui_selectpreset->treeWidget->currentItem();
          if(!item)
              return;
          QTreeWidgetItem *parentItem = item->parent();
          QTreeWidgetItem *takenItem = nullptr;
          if(parentItem)
              takenItem  = parentItem->takeChild(parentItem->indexOfChild(item));
          else
              takenItem  = ui_selectpreset->treeWidget->takeTopLevelItem(ui_selectpreset->treeWidget->indexOfTopLevelItem(item));
          Q_ASSERT(takenItem==item);
          delete takenItem;
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • H Offline
        H Offline
        Helg1980
        wrote on last edited by
        #21

        Finally, I finished the program and ran it through 'valgrind'. The result was disappointing:

        valgrind --leak-check=full --leak-resolution=med /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/cine_encoder
        .
        .
        .
        ==2615== HEAP SUMMARY:
        ==2615==     in use at exit: 568,907 bytes in 7,703 blocks
        ==2615==   total heap usage: 880,287 allocs, 872,584 frees, 5,593,630,039 bytes allocated
        ==2615== 
        ==2615== 24 bytes in 1 blocks are definitely lost in loss record 89 of 557
        ==2615==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
        ==2615==    by 0xDE61E5E: XextCreateExtension (in /usr/lib/libXext.so.6.4.0)
        ==2615==    by 0x1074014B: ???
        ==2615==    by 0x1073775C: ???
        ==2615==    by 0x10662091: ??? (in /usr/lib/qt/plugins/xcbglintegrations/libqxcb-glx-integration.so)
        ==2615==    by 0xA28C084: QXcbWindow::create() (in /usr/lib/libQt5XcbQpa.so.5.15.1)
        ==2615==    by 0xA27A746: QXcbIntegration::createPlatformWindow(QWindow*) const (in /usr/lib/libQt5XcbQpa.so.5.15.1)
        ==2615==    by 0x5842F26: QWindowPrivate::create(bool, unsigned long long) (in /usr/lib/libQt5Gui.so.5.15.1)
        ==2615==    by 0x51F78A7: QWidgetPrivate::create() (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x51F7E20: QWidget::create(unsigned long long, bool, bool) (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x520551B: QWidgetPrivate::setVisible(bool) (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x117E3F: main (main.cpp:10)
        ==2615== 
        ==2615== 96 (64 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 316 of 557
        ==2615==    at 0x483ADEF: operator new(unsigned long) (vg_replace_malloc.c:342)
        ==2615==    by 0x159CCB: SelectPreset::SelectPreset(QWidget*) (selectpreset.cpp:28)
        ==2615==    by 0x129258: MainWindow::on_actionPreset_clicked() (mainwindow.cpp:1279)
        ==2615==    by 0x1659B3: MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (moc_mainwindow.cpp:156)
        ==2615==    by 0x165B5F: MainWindow::qt_metacall(QMetaObject::Call, int, void**) (moc_mainwindow.cpp:204)
        ==2615==    by 0x60B5D71: ??? (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0x52B5B22: QAbstractButton::clicked(bool) (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x52B64AB: ??? (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x52B7E52: ??? (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x52B8032: QAbstractButton::mouseReleaseEvent(QMouseEvent*) (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x5205B0D: QWidget::event(QEvent*) (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615==    by 0x51C4751: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQt5Widgets.so.5.15.1)
        ==2615== 
        ==2615== 160 bytes in 1 blocks are possibly lost in loss record 369 of 557
        ==2615==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
        ==2615==    by 0x60A8595: QObjectPrivate::addConnection(int, QObjectPrivate::Connection*) (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0x60AC9DE: QObjectPrivate::connectImpl(QObject const*, int, QObject const*, void**, QtPrivate::QSlotObjectBase*, Qt::ConnectionType, int const*, QMetaObject const*) (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0x60ACEB5: QObject::connectImpl(QObject const*, void**, QObject const*, void**, QtPrivate::QSlotObjectBase*, Qt::ConnectionType, int const*, QMetaObject const*) (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0xA3D1BBD: QDBusConnectionInterface::QDBusConnectionInterface(QDBusConnection const&, QObject*) (in /usr/lib/libQt5DBus.so.5.15.1)
        ==2615==    by 0xA3CEB3A: ??? (in /usr/lib/libQt5DBus.so.5.15.1)
        ==2615==    by 0xA3CFD13: ??? (in /usr/lib/libQt5DBus.so.5.15.1)
        ==2615==    by 0x60AB7E1: QObject::event(QEvent*) (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0x607ECAF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0x60817D2: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0x60D8303: ??? (in /usr/lib/libQt5Core.so.5.15.1)
        ==2615==    by 0x6A2CBFB: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6600.0)
        ==2615== 
        ==2615== 302 (256 direct, 46 indirect) bytes in 1 blocks are definitely lost in loss record 409 of 557
        ==2615==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
        ==2615==    by 0xA38F9E2: ??? (in /usr/lib/libfontconfig.so.1.12.0)
        ==2615==    by 0xA3902E4: ??? (in /usr/lib/libfontconfig.so.1.12.0)
        ==2615==    by 0xA391BEB: ??? (in /usr/lib/libfontconfig.so.1.12.0)
        ==2615==    by 0xA399E59: ??? (in /usr/lib/libfontconfig.so.1.12.0)
        ==2615==    by 0xA5309E7: ??? (in /usr/lib/libexpat.so.1.6.11)
        ==2615==    by 0xA52EDDC: ??? (in /usr/lib/libexpat.so.1.6.11)
        ==2615==    by 0xA532620: ??? (in /usr/lib/libexpat.so.1.6.11)
        ==2615==    by 0xA5348CB: XML_ParseBuffer (in /usr/lib/libexpat.so.1.6.11)
        ==2615==    by 0xA397024: ??? (in /usr/lib/libfontconfig.so.1.12.0)
        ==2615==    by 0xA397657: ??? (in /usr/lib/libfontconfig.so.1.12.0)
        ==2615==    by 0xA397713: ??? (in /usr/lib/libfontconfig.so.1.12.0)
        ==2615== 
        ==2615== LEAK SUMMARY:
        ==2615==    definitely lost: 344 bytes in 3 blocks
        ==2615==    indirectly lost: 78 bytes in 3 blocks
        ==2615==      possibly lost: 160 bytes in 1 blocks
        ==2615==    still reachable: 568,305 bytes in 7,694 blocks
        ==2615==                       of which reachable via heuristic:
        ==2615==                         newarray           : 4,264 bytes in 1 blocks
        ==2615==         suppressed: 20 bytes in 2 blocks
        ==2615== Reachable blocks (those to which a pointer was found) are not shown.
        ==2615== To see them, rerun with: --leak-check=full --show-leak-kinds=all
        ==2615== 
        ==2615== Use --track-origins=yes to see where uninitialised values come from
        ==2615== For lists of detected and suppressed errors, rerun with: -s
        ==2615== ERROR SUMMARY: 107 errors from 107 contexts (suppressed: 0 from 0)
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #22

          @Helg1980 said in How do I delete the current QTreeWidget element correctly?:

          The result was disappointing:

          Why? There is only one leak which should interest you:

          ==2615== by 0x159CCB: SelectPreset::SelectPreset(QWidget*) (selectpreset.cpp:28)

          The rest are no real 'leaks' and can be ignored.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • H Offline
            H Offline
            Helg1980
            wrote on last edited by Helg1980
            #23

            Here is a part of the text where there may be an error:

            SelectPreset::SelectPreset(QWidget *parent) :
                QDialog(parent),
                ui_selectpreset(new Ui::SelectPreset)
            {
                ui_selectpreset->setupUi(this);
                ui_selectpreset->treeWidget->clear();
                int n =  _preset_table[0].size();
                int m = _preset_table.size();
                QString type;
                QColor color;
                color.setRgba(qRgb(120, 120, 150));
                QFont font;
                font.setBold(true);
                QTreeWidgetItem *item = new QTreeWidgetItem();    //    line 28  -  deleted this line
                for (int i = 0; i < n; i++) {
                    type = _preset_table[23][i];
                    if (type == "TopLewelItem") {
                        QTreeWidgetItem *root = new QTreeWidgetItem();
                        root->setText(0, _preset_table[0][i]);
                        ui_selectpreset->treeWidget->addTopLevelItem(root);
                        ui_selectpreset->treeWidget->setCurrentItem(root);
                        root->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
                        root->setFont(0, font);
                        root->setForeground(0, color);
                    };
                    if (type == "ChildItem") {
                        item = ui_selectpreset->treeWidget->currentItem();   // replaced with: QTreeWidgetItem *item =  ....
                        QTreeWidgetItem *child = new QTreeWidgetItem();
                        for (int j = 0; j < 23; j++) {
                            child->setText(j, _preset_table[j][i]);
                        };
                        child->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
                        item->addChild(child);
                    };
                };
                item = ui_selectpreset->treeWidget->topLevelItem(pos_top)->child(pos_cld);   // replaced with: QTreeWidgetItem *item =  ....
                ui_selectpreset->treeWidget->setCurrentItem(item);
                std::cout << n << " x " << m << std::endl; // Table size
                ui_selectpreset->treeWidget->expandAll();
                for (int i=1; i<=24; i++) {
                    ui_selectpreset->treeWidget->hideColumn(i);
                };
                QAction *addsection = new QAction(tr("Add section"), this);
                QAction *addpreset = new QAction(tr("Add new preset"), this);
                connect(addsection, &QAction::triggered, this, &SelectPreset::add_section);
                connect(addpreset, &QAction::triggered, this, &SelectPreset::add_preset);
                QMenu* menu = new QMenu(this);
                menu->addAction(addsection);
                menu->addAction(addpreset);
                menu->setStyleSheet("QMenu {background-color: rgb(5, 20, 25);} "
                                    "QMenu::item {background-color: transparent;} "
                                    "QMenu::item:selected {background-color: rgb(5, 40, 45);}");
                ui_selectpreset->actionAdd_preset->setMenu(menu);
            }
            
            JonBJ 1 Reply Last reply
            0
            • H Helg1980

              Here is a part of the text where there may be an error:

              SelectPreset::SelectPreset(QWidget *parent) :
                  QDialog(parent),
                  ui_selectpreset(new Ui::SelectPreset)
              {
                  ui_selectpreset->setupUi(this);
                  ui_selectpreset->treeWidget->clear();
                  int n =  _preset_table[0].size();
                  int m = _preset_table.size();
                  QString type;
                  QColor color;
                  color.setRgba(qRgb(120, 120, 150));
                  QFont font;
                  font.setBold(true);
                  QTreeWidgetItem *item = new QTreeWidgetItem();    //    line 28  -  deleted this line
                  for (int i = 0; i < n; i++) {
                      type = _preset_table[23][i];
                      if (type == "TopLewelItem") {
                          QTreeWidgetItem *root = new QTreeWidgetItem();
                          root->setText(0, _preset_table[0][i]);
                          ui_selectpreset->treeWidget->addTopLevelItem(root);
                          ui_selectpreset->treeWidget->setCurrentItem(root);
                          root->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
                          root->setFont(0, font);
                          root->setForeground(0, color);
                      };
                      if (type == "ChildItem") {
                          item = ui_selectpreset->treeWidget->currentItem();   // replaced with: QTreeWidgetItem *item =  ....
                          QTreeWidgetItem *child = new QTreeWidgetItem();
                          for (int j = 0; j < 23; j++) {
                              child->setText(j, _preset_table[j][i]);
                          };
                          child->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
                          item->addChild(child);
                      };
                  };
                  item = ui_selectpreset->treeWidget->topLevelItem(pos_top)->child(pos_cld);   // replaced with: QTreeWidgetItem *item =  ....
                  ui_selectpreset->treeWidget->setCurrentItem(item);
                  std::cout << n << " x " << m << std::endl; // Table size
                  ui_selectpreset->treeWidget->expandAll();
                  for (int i=1; i<=24; i++) {
                      ui_selectpreset->treeWidget->hideColumn(i);
                  };
                  QAction *addsection = new QAction(tr("Add section"), this);
                  QAction *addpreset = new QAction(tr("Add new preset"), this);
                  connect(addsection, &QAction::triggered, this, &SelectPreset::add_section);
                  connect(addpreset, &QAction::triggered, this, &SelectPreset::add_preset);
                  QMenu* menu = new QMenu(this);
                  menu->addAction(addsection);
                  menu->addAction(addpreset);
                  menu->setStyleSheet("QMenu {background-color: rgb(5, 20, 25);} "
                                      "QMenu::item {background-color: transparent;} "
                                      "QMenu::item:selected {background-color: rgb(5, 40, 45);}");
                  ui_selectpreset->actionAdd_preset->setMenu(menu);
              }
              
              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #24

              @Helg1980 said in How do I delete the current QTreeWidget element correctly?:

              QTreeWidgetItem *item = new QTreeWidgetItem(); // line 28

              So, as the valgrind tells you, in all cases you do not use/overwrite this newed item without using it. Hence the leak.

              H 1 Reply Last reply
              1
              • JonBJ JonB

                @Helg1980 said in How do I delete the current QTreeWidget element correctly?:

                QTreeWidgetItem *item = new QTreeWidgetItem(); // line 28

                So, as the valgrind tells you, in all cases you do not use/overwrite this newed item without using it. Hence the leak.

                H Offline
                H Offline
                Helg1980
                wrote on last edited by
                #25
                This post is deleted!
                JonBJ 1 Reply Last reply
                0
                • H Helg1980

                  This post is deleted!

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #26

                  @Helg1980
                  So I see. So now has that leak gone away? That's all you are looking to resolve.

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    Helg1980
                    wrote on last edited by Helg1980
                    #27

                    It looks like the error has disappeared. I don't work very well with valgrind yet. So I understand that I only need to search for lines where there are links to my files.

                    ==7099== HEAP SUMMARY:
                    ==7099==     in use at exit: 571,790 bytes in 7,682 blocks
                    ==7099==   total heap usage: 833,977 allocs, 826,295 frees, 5,575,110,174 bytes allocated
                    ==7099== 
                    ==7099== 24 bytes in 1 blocks are definitely lost in loss record 94 of 561
                    ==7099==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
                    ==7099==    by 0xDE61E5E: XextCreateExtension (in /usr/lib/libXext.so.6.4.0)
                    ==7099==    by 0x1074014B: ???
                    ==7099==    by 0x1073775C: ???
                    ==7099==    by 0x10662091: ??? (in /usr/lib/qt/plugins/xcbglintegrations/libqxcb-glx-integration.so)
                    ==7099==    by 0xA28C084: QXcbWindow::create() (in /usr/lib/libQt5XcbQpa.so.5.15.1)
                    ==7099==    by 0xA27A746: QXcbIntegration::createPlatformWindow(QWindow*) const (in /usr/lib/libQt5XcbQpa.so.5.15.1)
                    ==7099==    by 0x5842F26: QWindowPrivate::create(bool, unsigned long long) (in /usr/lib/libQt5Gui.so.5.15.1)
                    ==7099==    by 0x51F78A7: QWidgetPrivate::create() (in /usr/lib/libQt5Widgets.so.5.15.1)
                    ==7099==    by 0x51F7E20: QWidget::create(unsigned long long, bool, bool) (in /usr/lib/libQt5Widgets.so.5.15.1)
                    ==7099==    by 0x520551B: QWidgetPrivate::setVisible(bool) (in /usr/lib/libQt5Widgets.so.5.15.1)
                    ==7099==    by 0x117E3F: main (main.cpp:10)
                    ==7099== 
                    ==7099== 160 bytes in 1 blocks are possibly lost in loss record 372 of 561
                    ==7099==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
                    ==7099==    by 0x60A8595: QObjectPrivate::addConnection(int, QObjectPrivate::Connection*) (in /usr/lib/libQt5Core.so.5.15.1)
                    ==7099==    by 0x60AC9DE: QObjectPrivate::connectImpl(QObject const*, int, QObject const*, void**, QtPrivate::QSlotObjectBase*, Qt::ConnectionType, int const*, QMetaObject const*) (in /usr/lib/libQt5Core.so.5.15.1)
                    ==7099==    by 0x60ACEB5: QObject::connectImpl(QObject const*, void**, QObject const*, void**, QtPrivate::QSlotObjectBase*, Qt::ConnectionType, int const*, QMetaObject const*) (in /usr/lib/libQt5Core.so.5.15.1)
                    ==7099==    by 0xA3D1BBD: QDBusConnectionInterface::QDBusConnectionInterface(QDBusConnection const&, QObject*) (in /usr/lib/libQt5DBus.so.5.15.1)
                    ==7099==    by 0xA3CEB3A: ??? (in /usr/lib/libQt5DBus.so.5.15.1)
                    ==7099==    by 0xA3CFD13: ??? (in /usr/lib/libQt5DBus.so.5.15.1)
                    ==7099==    by 0x60AB7E1: QObject::event(QEvent*) (in /usr/lib/libQt5Core.so.5.15.1)
                    ==7099==    by 0x607ECAF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/libQt5Core.so.5.15.1)
                    ==7099==    by 0x60817D2: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (in /usr/lib/libQt5Core.so.5.15.1)
                    ==7099==    by 0x60D8303: ??? (in /usr/lib/libQt5Core.so.5.15.1)
                    ==7099==    by 0x6A2CBFB: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6600.0)
                    ==7099== 
                    ==7099== 302 (256 direct, 46 indirect) bytes in 1 blocks are definitely lost in loss record 414 of 561
                    ==7099==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
                    ==7099==    by 0xA38F9E2: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                    ==7099==    by 0xA3902E4: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                    ==7099==    by 0xA391BEB: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                    ==7099==    by 0xA399E59: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                    ==7099==    by 0xA5309E7: ??? (in /usr/lib/libexpat.so.1.6.11)
                    ==7099==    by 0xA52EDDC: ??? (in /usr/lib/libexpat.so.1.6.11)
                    ==7099==    by 0xA532620: ??? (in /usr/lib/libexpat.so.1.6.11)
                    ==7099==    by 0xA5348CB: XML_ParseBuffer (in /usr/lib/libexpat.so.1.6.11)
                    ==7099==    by 0xA397024: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                    ==7099==    by 0xA397657: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                    ==7099==    by 0xA397713: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                    ==7099== 
                    ==7099== LEAK SUMMARY:
                    ==7099==    definitely lost: 280 bytes in 2 blocks
                    ==7099==    indirectly lost: 46 bytes in 2 blocks
                    ==7099==      possibly lost: 160 bytes in 1 blocks
                    ==7099==    still reachable: 571,284 bytes in 7,675 blocks
                    ==7099==                       of which reachable via heuristic:
                    ==7099==                         newarray           : 4,264 bytes in 1 blocks
                    ==7099==         suppressed: 20 bytes in 2 blocks
                    ==7099== Reachable blocks (those to which a pointer was found) are not shown.
                    ==7099== To see them, rerun with: --leak-check=full --show-leak-kinds=all
                    ==7099== 
                    ==7099== Use --track-origins=yes to see where uninitialised values come from
                    ==7099== For lists of detected and suppressed errors, rerun with: -s
                    ==7099== ERROR SUMMARY: 80 errors from 80 contexts (suppressed: 0 from 0)
                    
                    JonBJ 1 Reply Last reply
                    0
                    • H Helg1980

                      It looks like the error has disappeared. I don't work very well with valgrind yet. So I understand that I only need to search for lines where there are links to my files.

                      ==7099== HEAP SUMMARY:
                      ==7099==     in use at exit: 571,790 bytes in 7,682 blocks
                      ==7099==   total heap usage: 833,977 allocs, 826,295 frees, 5,575,110,174 bytes allocated
                      ==7099== 
                      ==7099== 24 bytes in 1 blocks are definitely lost in loss record 94 of 561
                      ==7099==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
                      ==7099==    by 0xDE61E5E: XextCreateExtension (in /usr/lib/libXext.so.6.4.0)
                      ==7099==    by 0x1074014B: ???
                      ==7099==    by 0x1073775C: ???
                      ==7099==    by 0x10662091: ??? (in /usr/lib/qt/plugins/xcbglintegrations/libqxcb-glx-integration.so)
                      ==7099==    by 0xA28C084: QXcbWindow::create() (in /usr/lib/libQt5XcbQpa.so.5.15.1)
                      ==7099==    by 0xA27A746: QXcbIntegration::createPlatformWindow(QWindow*) const (in /usr/lib/libQt5XcbQpa.so.5.15.1)
                      ==7099==    by 0x5842F26: QWindowPrivate::create(bool, unsigned long long) (in /usr/lib/libQt5Gui.so.5.15.1)
                      ==7099==    by 0x51F78A7: QWidgetPrivate::create() (in /usr/lib/libQt5Widgets.so.5.15.1)
                      ==7099==    by 0x51F7E20: QWidget::create(unsigned long long, bool, bool) (in /usr/lib/libQt5Widgets.so.5.15.1)
                      ==7099==    by 0x520551B: QWidgetPrivate::setVisible(bool) (in /usr/lib/libQt5Widgets.so.5.15.1)
                      ==7099==    by 0x117E3F: main (main.cpp:10)
                      ==7099== 
                      ==7099== 160 bytes in 1 blocks are possibly lost in loss record 372 of 561
                      ==7099==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
                      ==7099==    by 0x60A8595: QObjectPrivate::addConnection(int, QObjectPrivate::Connection*) (in /usr/lib/libQt5Core.so.5.15.1)
                      ==7099==    by 0x60AC9DE: QObjectPrivate::connectImpl(QObject const*, int, QObject const*, void**, QtPrivate::QSlotObjectBase*, Qt::ConnectionType, int const*, QMetaObject const*) (in /usr/lib/libQt5Core.so.5.15.1)
                      ==7099==    by 0x60ACEB5: QObject::connectImpl(QObject const*, void**, QObject const*, void**, QtPrivate::QSlotObjectBase*, Qt::ConnectionType, int const*, QMetaObject const*) (in /usr/lib/libQt5Core.so.5.15.1)
                      ==7099==    by 0xA3D1BBD: QDBusConnectionInterface::QDBusConnectionInterface(QDBusConnection const&, QObject*) (in /usr/lib/libQt5DBus.so.5.15.1)
                      ==7099==    by 0xA3CEB3A: ??? (in /usr/lib/libQt5DBus.so.5.15.1)
                      ==7099==    by 0xA3CFD13: ??? (in /usr/lib/libQt5DBus.so.5.15.1)
                      ==7099==    by 0x60AB7E1: QObject::event(QEvent*) (in /usr/lib/libQt5Core.so.5.15.1)
                      ==7099==    by 0x607ECAF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/libQt5Core.so.5.15.1)
                      ==7099==    by 0x60817D2: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (in /usr/lib/libQt5Core.so.5.15.1)
                      ==7099==    by 0x60D8303: ??? (in /usr/lib/libQt5Core.so.5.15.1)
                      ==7099==    by 0x6A2CBFB: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6600.0)
                      ==7099== 
                      ==7099== 302 (256 direct, 46 indirect) bytes in 1 blocks are definitely lost in loss record 414 of 561
                      ==7099==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
                      ==7099==    by 0xA38F9E2: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                      ==7099==    by 0xA3902E4: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                      ==7099==    by 0xA391BEB: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                      ==7099==    by 0xA399E59: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                      ==7099==    by 0xA5309E7: ??? (in /usr/lib/libexpat.so.1.6.11)
                      ==7099==    by 0xA52EDDC: ??? (in /usr/lib/libexpat.so.1.6.11)
                      ==7099==    by 0xA532620: ??? (in /usr/lib/libexpat.so.1.6.11)
                      ==7099==    by 0xA5348CB: XML_ParseBuffer (in /usr/lib/libexpat.so.1.6.11)
                      ==7099==    by 0xA397024: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                      ==7099==    by 0xA397657: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                      ==7099==    by 0xA397713: ??? (in /usr/lib/libfontconfig.so.1.12.0)
                      ==7099== 
                      ==7099== LEAK SUMMARY:
                      ==7099==    definitely lost: 280 bytes in 2 blocks
                      ==7099==    indirectly lost: 46 bytes in 2 blocks
                      ==7099==      possibly lost: 160 bytes in 1 blocks
                      ==7099==    still reachable: 571,284 bytes in 7,675 blocks
                      ==7099==                       of which reachable via heuristic:
                      ==7099==                         newarray           : 4,264 bytes in 1 blocks
                      ==7099==         suppressed: 20 bytes in 2 blocks
                      ==7099== Reachable blocks (those to which a pointer was found) are not shown.
                      ==7099== To see them, rerun with: --leak-check=full --show-leak-kinds=all
                      ==7099== 
                      ==7099== Use --track-origins=yes to see where uninitialised values come from
                      ==7099== For lists of detected and suppressed errors, rerun with: -s
                      ==7099== ERROR SUMMARY: 80 errors from 80 contexts (suppressed: 0 from 0)
                      
                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #28

                      @Helg1980
                      Are you running valgrind yourself with those command-line arguments? I run it from inside Qt Creator, from the menu item. I (Ubuntu 20.04) always get exactly 32 leaks, which with the default of the checkbox which says something about "don't report system ones" being checked, are always suppressed, so I don't see them. Any genuine ones from my own code are then the only ones reported.

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        Helg1980
                        wrote on last edited by
                        #29
                        This post is deleted!
                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          Helg1980
                          wrote on last edited by
                          #30

                          Here's what valgrind QtCreator gives me. There are 35 errors in total.

                          160 bytes in 1 blocks are possibly lost in loss record 6,742 of 8,837
                            in Ui_MainWindow::setupUi(QMainWindow*) in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/ui_mainwindow.h:556
                            1: malloc in /build/valgrind/src/valgrind-3.16.1/coregrind/m_replacemalloc/vg_replace_malloc.c:307
                            2: QObjectPrivate::addConnection(int, QObjectPrivate::Connection*) in /usr/lib/libQt5Core.so.5.15.1
                            3: /usr/lib/libQt5Core.so.5.15.1
                            4: QObject::connect(QObject const*, char const*, QObject const*, char const*, Qt::ConnectionType) in /usr/lib/libQt5Core.so.5.15.1
                            5: /usr/lib/libQt5Widgets.so.5.15.1
                            6: Ui_MainWindow::setupUi(QMainWindow*) in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/ui_mainwindow.h:556
                            7: MainWindow::MainWindow(QWidget*) in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/cine-encoder-3.0/app/mainwindow.cpp:71
                            8: main in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/cine-encoder-3.0/app/main.cpp:9
                          288 bytes in 1 blocks are possibly lost in loss record 7,317 of 8,837
                            in Ui_MainWindow::setupUi(QMainWindow*) in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/ui_mainwindow.h:556
                            1: malloc in /build/valgrind/src/valgrind-3.16.1/coregrind/m_replacemalloc/vg_replace_malloc.c:307
                            2: QObjectPrivate::addConnection(int, QObjectPrivate::Connection*) in /usr/lib/libQt5Core.so.5.15.1
                            3: /usr/lib/libQt5Core.so.5.15.1
                            4: QObject::connect(QObject const*, char const*, QObject const*, char const*, Qt::ConnectionType) in /usr/lib/libQt5Core.so.5.15.1
                            5: /usr/lib/libQt5Widgets.so.5.15.1
                            6: Ui_MainWindow::setupUi(QMainWindow*) in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/ui_mainwindow.h:556
                            7: MainWindow::MainWindow(QWidget*) in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/cine-encoder-3.0/app/mainwindow.cpp:71
                            8: main in /run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/cine-encoder-3.0/app/main.cpp:9
                          
                          1 Reply Last reply
                          0
                          • VRoninV Offline
                            VRoninV Offline
                            VRonin
                            wrote on last edited by
                            #31

                            All looks good to me, only false positives left

                            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                            ~Napoleon Bonaparte

                            On a crusade to banish setIndexWidget() from the holy land of Qt

                            1 Reply Last reply
                            0
                            • H Offline
                              H Offline
                              Helg1980
                              wrote on last edited by
                              #32

                              Thanks!

                              I'm still confused by these lines, I don't know what to do with it:

                              QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 27, 29, 35, 0'
                              QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 27, 29, 35, 0'
                              kf.kio.core: We got some errors while running testparm "Error loading services."
                              kf.kio.core: We got some errors while running 'net usershare info'
                              kf.kio.core: "Can't load /etc/samba/smb.conf - run testparm to debug it\n"
                              kf.kio.widgets.kdirmodel: No node found for item that was just removed: QUrl("file:///run/media/helg/GOODRAM-SDB/QtCreatorProjects/CineEncoder/build-cine_encoder-Desktop-Debug/Makefile")
                              
                              1 Reply Last reply
                              0
                              • Christian EhrlicherC Online
                                Christian EhrlicherC Online
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #33

                                @Helg1980 said in How do I delete the current QTreeWidget element correctly?:

                                QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 27, 29, 35, 0'

                                You have a css somewhere which defines a wrong color rgb value.

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                1 Reply Last reply
                                0

                                • Login

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