Browse Source

Fix possible crash when loading columns visual indexes

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
401693dccd
  1. 8
      src/transferlistwidget.cpp

8
src/transferlistwidget.cpp

@ -845,7 +845,7 @@ void TransferListWidget::saveColWidthList() {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList width_list; QStringList width_list;
QStringList new_width_list; QStringList new_width_list;
const short nbColumns = listModel->columnCount()-1; // HASH is hidden const short nbColumns = listModel->columnCount();
if(nbColumns <= 0) return; if(nbColumns <= 0) return;
const QString line = settings.value("TransferListColsWidth", QString()).toString(); const QString line = settings.value("TransferListColsWidth", QString()).toString();
if(!line.isEmpty()) { if(!line.isEmpty()) {
@ -881,16 +881,16 @@ bool TransferListWidget::loadColWidthList() {
if(line.isEmpty()) if(line.isEmpty())
return false; return false;
const QStringList width_list = line.split(" "); const QStringList width_list = line.split(" ");
if(width_list.size() != listModel->columnCount()-1) { const unsigned int listSize = width_list.size();
if(listSize != listModel->columnCount()) {
qDebug("Corrupted values for transfer list columns sizes"); qDebug("Corrupted values for transfer list columns sizes");
return false; return false;
} }
const unsigned int listSize = width_list.size();
for(unsigned int i=0; i<listSize; ++i) { for(unsigned int i=0; i<listSize; ++i) {
header()->resizeSection(i, width_list.at(i).toInt()); header()->resizeSection(i, width_list.at(i).toInt());
} }
const QList<int> visualIndexes = misc::intListfromStringList(settings.value(QString::fromUtf8("TransferListVisualIndexes")).toStringList()); const QList<int> visualIndexes = misc::intListfromStringList(settings.value(QString::fromUtf8("TransferListVisualIndexes")).toStringList());
if(visualIndexes.size() != listModel->columnCount()-1) { if(visualIndexes.size() != listModel->columnCount()) {
qDebug("Corrupted values for transfer list columns indexes"); qDebug("Corrupted values for transfer list columns indexes");
return false; return false;
} }

Loading…
Cancel
Save