[vlc-commits] qt: fix memory leaks when adding elements to the playlist
Pierre Lamot
git at videolan.org
Thu Jun 13 13:10:29 CEST 2019
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Jun 13 12:54:14 2019 +0200| [49bc057b2f77b193f65071d8eb4ab28c3ca424b0] | committer: Thomas Guillem
qt: fix memory leaks when adding elements to the playlist
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=49bc057b2f77b193f65071d8eb4ab28c3ca424b0
---
modules/gui/qt/components/mediacenter/mcmedialib.cpp | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/modules/gui/qt/components/mediacenter/mcmedialib.cpp b/modules/gui/qt/components/mediacenter/mcmedialib.cpp
index 2fdf3159a0..09358a7c2d 100644
--- a/modules/gui/qt/components/mediacenter/mcmedialib.cpp
+++ b/modules/gui/qt/components/mediacenter/mcmedialib.cpp
@@ -83,9 +83,9 @@ void MCMediaLib::addToPlaylist(const MLParentId & itemId)
if (itemId.type == VLC_ML_PARENT_UNKNOWN)
{
- input_item_t* item = vlc_ml_get_input_item( m_ml, itemId.id );
+ vlc::playlist::InputItemPtr item( vlc_ml_get_input_item( m_ml, itemId.id ), false );
if (item) {
- QVector<vlc::playlist::Media> medias = { vlc::playlist::Media(item) };
+ QVector<vlc::playlist::Media> medias = { vlc::playlist::Media(item.get()) };
m_intf->p_sys->p_mainPlaylistController->append(medias, false);
}
}
@@ -100,8 +100,8 @@ void MCMediaLib::addToPlaylist(const MLParentId & itemId)
auto mediaRange = ml_range_iterate<vlc_ml_media_t>( media_list );
QVector<vlc::playlist::Media> medias;
std::transform(mediaRange.begin(), mediaRange.end(), std::back_inserter(medias), [&](vlc_ml_media_t& m) {
- input_item_t* item = vlc_ml_get_input_item( m_ml, m.i_id );
- return vlc::playlist::Media(item);
+ vlc::playlist::InputItemPtr item(vlc_ml_get_input_item( m_ml, m.i_id ), false);
+ return vlc::playlist::Media(item.get());
});
m_intf->p_sys->p_mainPlaylistController->append(medias, false);
}
@@ -137,11 +137,10 @@ void MCMediaLib::addAndPlay(const MLParentId & itemId )
return;
if (itemId.type == VLC_ML_PARENT_UNKNOWN)
{
- input_item_t* item = vlc_ml_get_input_item( m_ml, itemId.id );
+ vlc::playlist::InputItemPtr item(vlc_ml_get_input_item( m_ml, itemId.id ), false);
if (item) {
- QVector<vlc::playlist::Media> medias = { vlc::playlist::Media(item) };
+ QVector<vlc::playlist::Media> medias = { vlc::playlist::Media(item.get()) };
m_intf->p_sys->p_mainPlaylistController->append(medias, true);
- input_item_Release( item );
}
}
else
@@ -155,11 +154,8 @@ void MCMediaLib::addAndPlay(const MLParentId & itemId )
auto mediaRange = ml_range_iterate<vlc_ml_media_t>( media_list );
QVector<vlc::playlist::Media> medias;
std::transform(mediaRange.begin(), mediaRange.end(), std::back_inserter(medias), [&](vlc_ml_media_t& m) {
- input_item_t* item = vlc_ml_get_input_item( m_ml, m.i_id );
- auto res = vlc::playlist::Media(item);
- if ( item )
- input_item_Release( item );
- return res;
+ vlc::playlist::InputItemPtr item(vlc_ml_get_input_item( m_ml, m.i_id ), false);
+ return vlc::playlist::Media(item.get());
});
m_intf->p_sys->p_mainPlaylistController->append(medias, true);
}
More information about the vlc-commits
mailing list