mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Add more vector length checks
This commit is contained in:
parent
7bd4a1b849
commit
a940917144
@ -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
|
||||||
|
@ -499,10 +499,10 @@ 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);
|
Q_ASSERT(priorities.size() == t->num_files());
|
||||||
|
|
||||||
for (unsigned int i=0; i<nbFiles; ++i) {
|
for (unsigned int i=0; i<priorities.size(); ++i) {
|
||||||
if (priorities[i] > 0)
|
if (priorities[i] > 0)
|
||||||
torrent_size += t->file_at(i).size;
|
torrent_size += t->file_at(i).size;
|
||||||
}
|
}
|
||||||
@ -596,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ void TorrentContentModel::updateFilesProgress(const std::vector<libtorrent::size
|
|||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
Q_ASSERT(m_filesIndex.size() == (int)fp.size());
|
Q_ASSERT(m_filesIndex.size() == (int)fp.size());
|
||||||
|
if (m_filesIndex.size() != (int)fp.size()) return;
|
||||||
for (uint i=0; i<fp.size(); ++i) {
|
for (uint i=0; i<fp.size(); ++i) {
|
||||||
m_filesIndex[i]->setProgress(fp[i]);
|
m_filesIndex[i]->setProgress(fp[i]);
|
||||||
}
|
}
|
||||||
@ -59,16 +60,18 @@ void TorrentContentModel::updateFilesProgress(const std::vector<libtorrent::size
|
|||||||
void TorrentContentModel::updateFilesPriorities(const std::vector<int> &fprio)
|
void TorrentContentModel::updateFilesPriorities(const std::vector<int> &fprio)
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
Q_ASSERT(m_filesIndex.size() == (int)fprio.size());
|
||||||
|
if (m_filesIndex.size() != (int)fprio.size()) return;
|
||||||
for (uint i=0; i<fprio.size(); ++i) {
|
for (uint i=0; i<fprio.size(); ++i) {
|
||||||
m_filesIndex[i]->setPriority(fprio[i]);
|
m_filesIndex[i]->setPriority(fprio[i]);
|
||||||
}
|
}
|
||||||
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> TorrentContentModel::getFilesPriorities(unsigned int nbFiles) const
|
std::vector<int> TorrentContentModel::getFilesPriorities() const
|
||||||
{
|
{
|
||||||
std::vector<int> prio;
|
std::vector<int> prio;
|
||||||
for (uint i=0; i<nbFiles; ++i) {
|
for (uint i=0; i<m_filesIndex.size(); ++i) {
|
||||||
prio.push_back(m_filesIndex[i]->getPriority());
|
prio.push_back(m_filesIndex[i]->getPriority());
|
||||||
}
|
}
|
||||||
return prio;
|
return prio;
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
void updateFilesProgress(const std::vector<libtorrent::size_type>& fp);
|
void updateFilesProgress(const std::vector<libtorrent::size_type>& fp);
|
||||||
void updateFilesPriorities(const std::vector<int> &fprio);
|
void updateFilesPriorities(const std::vector<int> &fprio);
|
||||||
std::vector<int> getFilesPriorities(unsigned int nbFiles) const;
|
std::vector<int> getFilesPriorities() const;
|
||||||
bool allFiltered() const;
|
bool allFiltered() const;
|
||||||
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const;
|
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const;
|
||||||
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||||
|
Loading…
Reference in New Issue
Block a user