Possible fix for crash when deleting queued songs from playlist
See #527
This commit is contained in:
@@ -46,7 +46,7 @@ const char *Queue::kRowsMimetype = "application/x-strawberry-queue-rows";
|
|||||||
|
|
||||||
Queue::Queue(Playlist *parent) : QAbstractProxyModel(parent), playlist_(parent), total_length_ns_(0) {
|
Queue::Queue(Playlist *parent) : QAbstractProxyModel(parent), playlist_(parent), total_length_ns_(0) {
|
||||||
|
|
||||||
connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength()));
|
signal_item_count_changed_ = connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength()));
|
||||||
connect(this, SIGNAL(TotalLengthChanged(quint64)), SLOT(UpdateSummaryText()));
|
connect(this, SIGNAL(TotalLengthChanged(quint64)), SLOT(UpdateSummaryText()));
|
||||||
|
|
||||||
UpdateSummaryText();
|
UpdateSummaryText();
|
||||||
@@ -113,6 +113,8 @@ void Queue::SourceDataChanged(const QModelIndex &top_left, const QModelIndex &bo
|
|||||||
|
|
||||||
void Queue::SourceLayoutChanged() {
|
void Queue::SourceLayoutChanged() {
|
||||||
|
|
||||||
|
disconnect(signal_item_count_changed_);
|
||||||
|
|
||||||
for (int i = 0; i < source_indexes_.count(); ++i) {
|
for (int i = 0; i < source_indexes_.count(); ++i) {
|
||||||
if (!source_indexes_[i].isValid()) {
|
if (!source_indexes_[i].isValid()) {
|
||||||
beginRemoveRows(QModelIndex(), i, i);
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
@@ -121,6 +123,9 @@ void Queue::SourceLayoutChanged() {
|
|||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signal_item_count_changed_ = connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength()));
|
||||||
|
|
||||||
emit ItemCountChanged(this->ItemCount());
|
emit ItemCountChanged(this->ItemCount());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ class Queue : public QAbstractProxyModel {
|
|||||||
QList<QPersistentModelIndex> source_indexes_;
|
QList<QPersistentModelIndex> source_indexes_;
|
||||||
const Playlist *playlist_;
|
const Playlist *playlist_;
|
||||||
quint64 total_length_ns_;
|
quint64 total_length_ns_;
|
||||||
|
QMetaObject::Connection signal_item_count_changed_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user