diff --git a/src/playlist/queue.cpp b/src/playlist/queue.cpp index 370000f64..c633f38cc 100644 --- a/src/playlist/queue.cpp +++ b/src/playlist/queue.cpp @@ -29,7 +29,8 @@ const char* Queue::kRowsMimetype = "application/x-clementine-queue-rows"; Queue::Queue(Playlist* parent) : QAbstractProxyModel(parent), playlist_(parent), total_length_ns_(0) { - connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength())); + count_changed_ = + connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength())); connect(this, SIGNAL(TotalLengthChanged(quint64)), SLOT(UpdateSummaryText())); UpdateSummaryText(); @@ -91,6 +92,9 @@ void Queue::SourceDataChanged(const QModelIndex& top_left, } void Queue::SourceLayoutChanged() { + // Temporarily disconnect this signal to prevent UpdateTotalLength from + // being called when SourceDataChanged is handled during this scrub. + disconnect(count_changed_); for (int i = 0; i < source_indexes_.count(); ++i) { if (!source_indexes_[i].isValid()) { beginRemoveRows(QModelIndex(), i, i); @@ -100,6 +104,9 @@ void Queue::SourceLayoutChanged() { --i; } } + // Re-connect before emitting the signal ourselves. + count_changed_ = + connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength())); emit ItemCountChanged(this->ItemCount()); } diff --git a/src/playlist/queue.h b/src/playlist/queue.h index f840e733e..73271b1d4 100644 --- a/src/playlist/queue.h +++ b/src/playlist/queue.h @@ -86,6 +86,7 @@ class Queue : public QAbstractProxyModel { QList source_indexes_; const Playlist* playlist_; quint64 total_length_ns_; + QMetaObject::Connection count_changed_; }; #endif // QUEUE_H