[vlc-commits] qt: don't update the model when the callback comes from another node in NetworkMediaModel
Pierre Lamot
git at videolan.org
Fri Jan 24 11:37:57 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Jan 20 14:23:26 2020 +0100| [ecdc5a17cd5eab4573f90e8ea7a631060ecdb056] | committer: Thomas Guillem
qt: don't update the model when the callback comes from another node in NetworkMediaModel
this fixes issues when we get the callback from a node after we changes view
and end up displaying the content of a folder within the device view
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ecdc5a17cd5eab4573f90e8ea7a631060ecdb056
---
modules/gui/qt/network/networkmediamodel.cpp | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/modules/gui/qt/network/networkmediamodel.cpp b/modules/gui/qt/network/networkmediamodel.cpp
index 2a229ff652..a7e96a2ac7 100644
--- a/modules/gui/qt/network/networkmediamodel.cpp
+++ b/modules/gui/qt/network/networkmediamodel.cpp
@@ -265,9 +265,12 @@ bool NetworkMediaModel::initializeMediaSources()
return true;
}
-void NetworkMediaModel::onItemCleared( MediaSourcePtr mediaSource, input_item_node_t*)
+void NetworkMediaModel::onItemCleared( MediaSourcePtr mediaSource, input_item_node_t* node)
{
- QMetaObject::invokeMethod(this, [this, mediaSource = std::move(mediaSource)]() {
+ InputItemPtr p_node { node->p_item };
+ QMetaObject::invokeMethod(this, [this, p_node = std::move(p_node), mediaSource = std::move(mediaSource)]() {
+ if (p_node != m_treeItem.media)
+ return;
input_item_node_t *res;
input_item_node_t *parent;
vlc_media_tree_Lock( m_treeItem.source->tree );
@@ -287,12 +290,12 @@ void NetworkMediaModel::onItemAdded( MediaSourcePtr mediaSource, input_item_node
{
InputItemPtr p_parent { parent->p_item };
QMetaObject::invokeMethod(this, [this, p_parent = std::move(p_parent), mediaSource = std::move(mediaSource), children, count]() {
- if ( p_parent.get() == m_treeItem.media.get() )
+ if ( p_parent == m_treeItem.media )
refreshMediaList( std::move( mediaSource ), children, count, false );
}, Qt::QueuedConnection);
}
-void NetworkMediaModel::onItemRemoved(MediaSourcePtr, input_item_node_t *,
+void NetworkMediaModel::onItemRemoved(MediaSourcePtr, input_item_node_t * node,
input_item_node_t *const children[],
size_t count )
{
@@ -301,7 +304,11 @@ void NetworkMediaModel::onItemRemoved(MediaSourcePtr, input_item_node_t *,
for ( auto i = 0u; i < count; ++i )
itemList.emplace_back( children[i]->p_item );
- QMetaObject::invokeMethod(this, [this, itemList=std::move(itemList)]() {
+ InputItemPtr p_node { node->p_item };
+ QMetaObject::invokeMethod(this, [this, p_node=std::move(p_node), itemList=std::move(itemList)]() {
+ if (p_node != m_treeItem.media)
+ return;
+
for (auto p_item : itemList)
{
QUrl itemUri = QUrl::fromEncoded(p_item->psz_uri);
@@ -329,9 +336,13 @@ void NetworkMediaModel::onItemRemoved(MediaSourcePtr, input_item_node_t *,
}, Qt::QueuedConnection);
}
-void NetworkMediaModel::onItemPreparseEnded(MediaSourcePtr, input_item_node_t*, enum input_item_preparse_status)
+void NetworkMediaModel::onItemPreparseEnded(MediaSourcePtr, input_item_node_t* node, enum input_item_preparse_status)
{
- QMetaObject::invokeMethod(this, [this]() {
+ InputItemPtr p_node { node->p_item };
+ QMetaObject::invokeMethod(this, [this, p_node=std::move(p_node)]() {
+ if (p_node != m_treeItem.media)
+ return;
+
m_parsingPending = false;
emit parsingPendingChanged(false);
});
More information about the vlc-commits
mailing list