After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 788457 - Memory leak in videowidgettest.cpp
Memory leak in videowidgettest.cpp
Status: RESOLVED INVALID
Product: GStreamer
Classification: Platform
Component: qt-gstreamer
1.13.x
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-10-03 04:24 UTC by Renu
Modified: 2017-10-05 09:34 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Renu 2017-10-03 04:24:16 UTC
Hi

qt-gstreamer\tests\manual\videowidgettest.cpp


VideoWidgetTest::VideoWidgetTest(QWidget *parent, Qt::WindowFlags f)
    : QWidget(parent, f)
{
    m_ui.setupUi(this);

    QButtonGroup *group = new QButtonGroup(this);
    group->addButton(m_ui.playingButton, QGst::StatePlaying);
    group->addButton(m_ui.pausedButton, QGst::StatePaused);
    group->addButton(m_ui.readyButton, QGst::StateReady);
    group->addButton(m_ui.nullButton, QGst::StateNull);
    connect(group, SIGNAL(buttonClicked(int)), SLOT(onButtonClicked(int)));

    m_pipeline = QGst::Pipeline::create();
    m_src = QGst::ElementFactory::make("videotestsrc");

    if (!m_src) {
        throw std::runtime_error("Unable to create a videotestsrc");
    }

    m_pipeline->add(m_src);
}



Here when m_src is not created , then we should free the group element memory.

if (!m_src) {
        delete group;
        throw std::runtime_error("Unable to create a videotestsrc");
    }
Comment 1 George Kiagiadakis 2017-10-05 09:34:34 UTC
I disagree.

"group" in this scope is a QButtonGroup, which is a QWidget, which is a QObject and it is constructed with "this" as a parent, therefore it "belongs" to the QObject ancestor instance of this class.

When an exception is thrown in a constructor, the destructor of this object is not called, but the destructors of its ancestor classes *are* called, since they have successfully completed their execution already (in other words, the ancestor QObject is a fully constructed instance at this point, therefore it needs to be destructed).

Therefore, the QObject destructor of this instance *is* called after "throw", so the QButtonGroup is automatically destroyed, together with all the other widgets that are set up in m_ui.setupUi(this);