Browse Source

- Fix several possible crashes when using Magnet URI (because they don't have metadata in the beginning)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
497cb07852
  1. 5
      src/propertieswidget.cpp
  2. 2
      src/proplistdelegate.h
  3. 2
      src/trackerlist.h

5
src/propertieswidget.cpp

@ -204,6 +204,7 @@ Bittorrent* PropertiesWidget::getBTSession() const {
} }
void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
clear();
h = _h; h = _h;
if(!h.is_valid()) { if(!h.is_valid()) {
clear(); clear();
@ -330,10 +331,12 @@ void PropertiesWidget::loadDynamicData() {
// Downloaded pieces // Downloaded pieces
downloaded_pieces->setProgress(h.pieces()); downloaded_pieces->setProgress(h.pieces());
// Pieces availability // Pieces availability
if(h.has_metadata()) {
std::vector<int> avail; std::vector<int> avail;
h.piece_availability(avail); h.piece_availability(avail);
double avail_average = pieces_availability->setAvailability(avail); double avail_average = pieces_availability->setAvailability(avail);
avail_average_lbl->setText(QString::number(avail_average, 'f', 1)); avail_average_lbl->setText(QString::number(avail_average, 'f', 1));
}
// Progress // Progress
progress_lbl->setText(QString::number(h.progress()*100., 'f', 1)+"%"); progress_lbl->setText(QString::number(h.progress()*100., 'f', 1)+"%");
} else { } else {
@ -353,11 +356,13 @@ void PropertiesWidget::loadDynamicData() {
} }
if(stackedProperties->currentIndex() == FILES_TAB) { if(stackedProperties->currentIndex() == FILES_TAB) {
// Files progress // Files progress
if(h.has_metadata()) {
std::vector<size_type> fp; std::vector<size_type> fp;
h.file_progress(fp); h.file_progress(fp);
PropListModel->updateFilesPriorities(h.file_priorities()); PropListModel->updateFilesPriorities(h.file_priorities());
PropListModel->updateFilesProgress(fp); PropListModel->updateFilesProgress(fp);
} }
}
} catch(invalid_handle e) {} } catch(invalid_handle e) {}
} }

2
src/proplistdelegate.h

@ -122,7 +122,7 @@ public:
if(index.column() != PRIORITY) return 0; if(index.column() != PRIORITY) return 0;
if(properties) { if(properties) {
QTorrentHandle h = properties->getCurrentTorrent(); QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid() || h.is_seed()) return 0; if(!h.is_valid() || h.is_seed() || !h.has_metadata()) return 0;
} }
QComboBox* editor = new QComboBox(parent); QComboBox* editor = new QComboBox(parent);
editor->setFocusPolicy(Qt::StrongFocus); editor->setFocusPolicy(Qt::StrongFocus);

2
src/trackerlist.h

@ -275,6 +275,8 @@ public slots:
} }
void showTrackerListMenu(QPoint) { void showTrackerListMenu(QPoint) {
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid() || !h.has_metadata()) return;
QList<QTreeWidgetItem*> selected_items = getSelectedTrackerItems(); QList<QTreeWidgetItem*> selected_items = getSelectedTrackerItems();
QMenu menu; QMenu menu;
// Add actions // Add actions

Loading…
Cancel
Save