[vlc-commits] qt: networkmediamodel: move std::vector instead of pointer
Alexandre Janniaux
git at videolan.org
Wed Jan 22 10:08:47 CET 2020
vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Fri Jan 17 15:30:53 2020 +0100| [f8d1f140e2bb6d76b382dc639ada31b3de26cf1c] | committer: Thomas Guillem
qt: networkmediamodel: move std::vector instead of pointer
Creating a pointer with new is unprotected and unecessary here. The
vector itself can be moved without much cost.
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f8d1f140e2bb6d76b382dc639ada31b3de26cf1c
---
modules/gui/qt/network/networkmediamodel.cpp | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/modules/gui/qt/network/networkmediamodel.cpp b/modules/gui/qt/network/networkmediamodel.cpp
index 1dbd87b841..2fb3237f4a 100644
--- a/modules/gui/qt/network/networkmediamodel.cpp
+++ b/modules/gui/qt/network/networkmediamodel.cpp
@@ -328,7 +328,7 @@ void NetworkMediaModel::refreshMediaList( MediaSourcePtr mediaSource,
input_item_node_t* const children[], size_t count,
bool clear )
{
- auto items = new std::vector<Item>;
+ std::vector<Item> items;
for ( auto i = 0u; i < count; ++i )
{
auto it = children[i]->p_item;
@@ -351,18 +351,17 @@ void NetworkMediaModel::refreshMediaList( MediaSourcePtr mediaSource,
item.indexed = false;
}
item.tree = NetworkTreeItem( mediaSource, it );
- items->push_back( std::move( item ) );
+ items.push_back( std::move( item ) );
}
- QMetaObject::invokeMethod(this, [this, clear, items]() {
- std::unique_ptr<std::vector<Item>> itemsPtr{ items };
+ QMetaObject::invokeMethod(this, [this, clear, items=std::move(items)]() {
if ( clear == true )
{
beginResetModel();
m_items.erase( begin( m_items ) , end( m_items ) );
}
else
- beginInsertRows( {}, m_items.size(), m_items.size() + items->size() - 1 );
- std::move( begin( *items ), end( *items ), std::back_inserter( m_items ) );
+ beginInsertRows( {}, m_items.size(), m_items.size() + items.size() - 1 );
+ std::move( begin( items ), end( items ), std::back_inserter( m_items ) );
if ( clear == true )
endResetModel();
else
More information about the vlc-commits
mailing list