Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72483

QComboBox::setItemDelegate() does not take ownership as stated in documenation.

    XMLWordPrintable

Details

    • All
    • 089d54f06ff327f5212cb08fdbcb540066357dd5 (qt/qtbase/dev)

    Description

      It could be that I misunderstand the documentation, but for QComboBox::setItemDelegate() the documentation states:

      Sets the item delegate for the popup list view. The combobox takes ownership of the delegate.

      Now, I had the following code result in memory leaks:

      if (const auto comboBox = qobject_cast<QComboBox *>(widget))

      { comboBox->setItemDelegate(std::make_unique<QStyledItemDelegate>().release()); }

      It's easily fixed of course. I can pass the comboBox variable to the constructor of the QStyledItemDelegate to serve as its parent QObject.

      However, I thought I'd mention it anyway. To me it seems like the documentation is wrong about the QComboBox taking ownership of the delegate.

      Regards, Arjen

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            chehrlic Christian Ehrlicher
            arjen Arjen Hoogesteger
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes