mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
BUGFIX: Fix possible crash when showing torrent content (closes #1002586)
This commit is contained in:
parent
89a1eb1bca
commit
96f619b486
4 changed files with 22 additions and 19 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.9.10
|
||||||
|
- BUGFIX: Fix possible crash when showing torrent content (closes #1002586)
|
||||||
|
|
||||||
* Sun May 20 - Christophe Dumez <chris@qbittorrent.org> - v2.9.9
|
* Sun May 20 - Christophe Dumez <chris@qbittorrent.org> - v2.9.9
|
||||||
- BUGFIX: More reliable RSS feed parsing (closes #1001777)
|
- BUGFIX: More reliable RSS feed parsing (closes #1001777)
|
||||||
- BUGFIX: Better support for cookies in RSS
|
- BUGFIX: Better support for cookies in RSS
|
||||||
|
|
|
@ -652,7 +652,7 @@ void PropertiesWidget::deleteSelectedUrlSeeds(){
|
||||||
|
|
||||||
bool PropertiesWidget::applyPriorities() {
|
bool PropertiesWidget::applyPriorities() {
|
||||||
qDebug("Saving files priorities");
|
qDebug("Saving files priorities");
|
||||||
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(h.get_torrent_info().num_files());
|
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities();
|
||||||
// Save first/last piece first option state
|
// Save first/last piece first option state
|
||||||
bool first_last_piece_first = h.first_last_piece_first();
|
bool first_last_piece_first = h.first_last_piece_first();
|
||||||
// Prioritize the files
|
// Prioritize the files
|
||||||
|
|
|
@ -501,10 +501,8 @@ void torrentAdditionDialog::updateDiskSpaceLabels() {
|
||||||
// Determine torrent size
|
// Determine torrent size
|
||||||
qulonglong torrent_size = 0;
|
qulonglong torrent_size = 0;
|
||||||
if(t->num_files() > 1) {
|
if(t->num_files() > 1) {
|
||||||
const unsigned int nbFiles = t->num_files();
|
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities();
|
||||||
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(nbFiles);
|
for(unsigned int i=0; i<priorities.size(); ++i) {
|
||||||
|
|
||||||
for(unsigned int i=0; i<nbFiles; ++i) {
|
|
||||||
if(priorities[i] > 0)
|
if(priorities[i] > 0)
|
||||||
torrent_size += t->file_at(i).size;
|
torrent_size += t->file_at(i).size;
|
||||||
}
|
}
|
||||||
|
@ -598,7 +596,7 @@ bool torrentAdditionDialog::allFiltered() const {
|
||||||
void torrentAdditionDialog::savePiecesPriorities(){
|
void torrentAdditionDialog::savePiecesPriorities(){
|
||||||
qDebug("Saving pieces priorities");
|
qDebug("Saving pieces priorities");
|
||||||
Q_ASSERT(!is_magnet);
|
Q_ASSERT(!is_magnet);
|
||||||
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities(t->num_files());
|
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities();
|
||||||
TorrentTempData::setFilesPriority(hash, priorities);
|
TorrentTempData::setFilesPriority(hash, priorities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,11 +338,10 @@ class TorrentFilesModel: public QAbstractItemModel {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TorrentFileItem *rootItem;
|
TorrentFileItem *rootItem;
|
||||||
TorrentFileItem **files_index;
|
std::vector<TorrentFileItem *> files_index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TorrentFilesModel(QObject *parent=0): QAbstractItemModel(parent) {
|
TorrentFilesModel(QObject *parent=0): QAbstractItemModel(parent) {
|
||||||
files_index = 0;
|
|
||||||
QList<QVariant> rootData;
|
QList<QVariant> rootData;
|
||||||
rootData << tr("Name") << tr("Size") << tr("Progress") << tr("Priority");
|
rootData << tr("Name") << tr("Size") << tr("Progress") << tr("Priority");
|
||||||
rootItem = new TorrentFileItem(rootData);
|
rootItem = new TorrentFileItem(rootData);
|
||||||
|
@ -350,13 +349,16 @@ public:
|
||||||
|
|
||||||
~TorrentFilesModel() {
|
~TorrentFilesModel() {
|
||||||
qDebug() << Q_FUNC_INFO << "ENTER";
|
qDebug() << Q_FUNC_INFO << "ENTER";
|
||||||
delete [] files_index;
|
|
||||||
delete rootItem;
|
delete rootItem;
|
||||||
qDebug() << Q_FUNC_INFO << "EXIT";
|
qDebug() << Q_FUNC_INFO << "EXIT";
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateFilesProgress(std::vector<libtorrent::size_type> fp) {
|
void updateFilesProgress(const std::vector<libtorrent::size_type>& fp) {
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
|
||||||
|
if (fp.size() != files_index.size())
|
||||||
|
return;
|
||||||
|
|
||||||
for(unsigned int i=0; i<fp.size(); ++i) {
|
for(unsigned int i=0; i<fp.size(); ++i) {
|
||||||
Q_ASSERT(fp[i] >= 0);
|
Q_ASSERT(fp[i] >= 0);
|
||||||
files_index[i]->setProgress(fp[i]);
|
files_index[i]->setProgress(fp[i]);
|
||||||
|
@ -366,6 +368,10 @@ public:
|
||||||
|
|
||||||
void updateFilesPriorities(const std::vector<int> &fprio) {
|
void updateFilesPriorities(const std::vector<int> &fprio) {
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
|
||||||
|
if (fprio.size() != files_index.size())
|
||||||
|
return;
|
||||||
|
|
||||||
for(unsigned int i=0; i<fprio.size(); ++i) {
|
for(unsigned int i=0; i<fprio.size(); ++i) {
|
||||||
//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]);
|
||||||
|
@ -373,9 +379,9 @@ public:
|
||||||
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> getFilesPriorities(unsigned int nbFiles) const {
|
std::vector<int> getFilesPriorities() const {
|
||||||
std::vector<int> prio;
|
std::vector<int> prio;
|
||||||
for(unsigned int i=0; i<nbFiles; ++i) {
|
for(unsigned int i=0; i<files_index.size(); ++i) {
|
||||||
//qDebug("Called getFilesPriorities: %d", files_index[i]->getPriority());
|
//qDebug("Called getFilesPriorities: %d", files_index[i]->getPriority());
|
||||||
prio.push_back(files_index[i]->getPriority());
|
prio.push_back(files_index[i]->getPriority());
|
||||||
}
|
}
|
||||||
|
@ -541,10 +547,7 @@ public:
|
||||||
void clear() {
|
void clear() {
|
||||||
qDebug("clear called");
|
qDebug("clear called");
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
if(files_index) {
|
files_index.clear();
|
||||||
delete [] files_index;
|
|
||||||
files_index = 0;
|
|
||||||
}
|
|
||||||
rootItem->deleteAllChildren();
|
rootItem->deleteAllChildren();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
@ -555,7 +558,7 @@ public:
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
// Initialize files_index array
|
// Initialize files_index array
|
||||||
qDebug("Torrent contains %d files", t.num_files());
|
qDebug("Torrent contains %d files", t.num_files());
|
||||||
files_index = new TorrentFileItem*[t.num_files()];
|
files_index.reserve(t.num_files());
|
||||||
|
|
||||||
TorrentFileItem *parent = this->rootItem;
|
TorrentFileItem *parent = this->rootItem;
|
||||||
TorrentFileItem *root_folder = parent;
|
TorrentFileItem *root_folder = parent;
|
||||||
|
@ -582,8 +585,7 @@ public:
|
||||||
current_parent = new_parent;
|
current_parent = new_parent;
|
||||||
}
|
}
|
||||||
// Actually create the file
|
// Actually create the file
|
||||||
TorrentFileItem *f = new TorrentFileItem(t, fentry, current_parent, i);
|
files_index.push_back(new TorrentFileItem(t, fentry, current_parent, i));
|
||||||
files_index[i] = f;
|
|
||||||
}
|
}
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue