mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Fix possible crash when changing the priority of a file
This commit is contained in:
parent
6ed4724e33
commit
9c57cca93c
@ -357,7 +357,7 @@ public:
|
|||||||
Q_ASSERT(fp[i] >= 0);
|
Q_ASSERT(fp[i] >= 0);
|
||||||
files_index[i]->setProgress(fp[i]);
|
files_index[i]->setProgress(fp[i]);
|
||||||
}
|
}
|
||||||
emit layoutChanged();
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateFilesPriorities(std::vector<int> fprio) {
|
void updateFilesPriorities(std::vector<int> fprio) {
|
||||||
@ -366,7 +366,7 @@ public:
|
|||||||
//qDebug("Called updateFilesPriorities with %d", fprio[i]);
|
//qDebug("Called updateFilesPriorities with %d", fprio[i]);
|
||||||
files_index[i]->setPriority(fprio[i]);
|
files_index[i]->setPriority(fprio[i]);
|
||||||
}
|
}
|
||||||
emit layoutChanged();
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> getFilesPriorities(unsigned int nbFiles) const {
|
std::vector<int> getFilesPriorities(unsigned int nbFiles) const {
|
||||||
@ -405,8 +405,8 @@ public:
|
|||||||
item->setPriority(prio::IGNORED);
|
item->setPriority(prio::IGNORED);
|
||||||
else
|
else
|
||||||
item->setPriority(prio::NORMAL);
|
item->setPriority(prio::NORMAL);
|
||||||
|
emit dataChanged(this->index(0,0), this->index(rowCount(), columnCount()));
|
||||||
emit filteredFilesChanged();
|
emit filteredFilesChanged();
|
||||||
emit dataChanged(this->index(0,0), this->index(rowCount(), 0));
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -536,14 +536,13 @@ public:
|
|||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
qDebug("clear called");
|
qDebug("clear called");
|
||||||
emit layoutAboutToBeChanged();
|
beginResetModel();
|
||||||
if(files_index) {
|
if(files_index) {
|
||||||
delete [] files_index;
|
delete [] files_index;
|
||||||
files_index = 0;
|
files_index = 0;
|
||||||
}
|
}
|
||||||
rootItem->deleteAllChildren();
|
rootItem->deleteAllChildren();
|
||||||
reset();
|
endResetModel();
|
||||||
emit layoutChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupModelData(const libtorrent::torrent_info &t) {
|
void setupModelData(const libtorrent::torrent_info &t) {
|
||||||
@ -590,21 +589,19 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void selectAll() {
|
void selectAll() {
|
||||||
emit layoutAboutToBeChanged();
|
|
||||||
for(int i=0; i<rootItem->childCount(); ++i) {
|
for(int i=0; i<rootItem->childCount(); ++i) {
|
||||||
TorrentFileItem *child = rootItem->child(i);
|
TorrentFileItem *child = rootItem->child(i);
|
||||||
if(child->getPriority() == prio::IGNORED)
|
if(child->getPriority() == prio::IGNORED)
|
||||||
child->setPriority(prio::NORMAL);
|
child->setPriority(prio::NORMAL);
|
||||||
}
|
}
|
||||||
emit layoutChanged();
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectNone() {
|
void selectNone() {
|
||||||
emit layoutAboutToBeChanged();
|
|
||||||
for(int i=0; i<rootItem->childCount(); ++i) {
|
for(int i=0; i<rootItem->childCount(); ++i) {
|
||||||
rootItem->child(i)->setPriority(prio::IGNORED);
|
rootItem->child(i)->setPriority(prio::IGNORED);
|
||||||
}
|
}
|
||||||
emit layoutChanged();
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -645,11 +642,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex parent(const QModelIndex & child) const {
|
QModelIndex parent(const QModelIndex & child) const {
|
||||||
if(!child.isValid()) return QModelIndex();
|
if(!child.isValid()) return QModelIndex();
|
||||||
Q_ASSERT(sourceModel());
|
QModelIndex sourceParent = m_model->parent(mapToSource(child));
|
||||||
QModelIndex sourceParent = sourceModel()->parent(mapToSource(child));
|
if(!sourceParent.isValid()) return QModelIndex();
|
||||||
if(!sourceParent.isValid()) return QModelIndex();
|
return mapFromSource(sourceParent);
|
||||||
return mapFromSource(sourceParent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -669,14 +665,14 @@ public slots:
|
|||||||
for(int i=0; i<rowCount(); ++i) {
|
for(int i=0; i<rowCount(); ++i) {
|
||||||
setData(index(i, 0), Qt::Checked, Qt::CheckStateRole);
|
setData(index(i, 0), Qt::Checked, Qt::CheckStateRole);
|
||||||
}
|
}
|
||||||
emit layoutChanged();
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectNone() {
|
void selectNone() {
|
||||||
for(int i=0; i<rowCount(); ++i) {
|
for(int i=0; i<rowCount(); ++i) {
|
||||||
setData(index(i, 0), Qt::Unchecked, Qt::CheckStateRole);
|
setData(index(i, 0), Qt::Unchecked, Qt::CheckStateRole);
|
||||||
}
|
}
|
||||||
emit layoutChanged();
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user