Browse Source

- Fix crash when a torrent contains empty files

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
d8c27ac8c4
  1. 3
      src/eventmanager.cpp
  2. 3
      src/torrentfilesmodel.h

3
src/eventmanager.cpp

@ -111,7 +111,10 @@ QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
file["name"] = name; file["name"] = name;
} }
file["size"] = misc::friendlyUnit((double)fi->size); file["size"] = misc::friendlyUnit((double)fi->size);
if(fi->size > 0)
file["progress"] = fp[i]/(double)fi->size; file["progress"] = fp[i]/(double)fi->size;
else
file["progress"] = 1.; // Empty file...
file["priority"] = priorities[i]; file["priority"] = priorities[i];
files << file; files << file;
++i; ++i;

3
src/torrentfilesmodel.h

@ -272,7 +272,10 @@ public:
void updateFilesProgress(std::vector<size_type> fp) { void updateFilesProgress(std::vector<size_type> fp) {
for(unsigned int i=0; i<fp.size(); ++i) { for(unsigned int i=0; i<fp.size(); ++i) {
TreeItem *item = files_index[i]; TreeItem *item = files_index[i];
if(item->getSize() > 0)
item->setProgress((float)fp[i]/(float)item->getSize()); item->setProgress((float)fp[i]/(float)item->getSize());
else
item->setProgress(1.); // Empty file...
} }
emit layoutChanged(); emit layoutChanged();
} }

Loading…
Cancel
Save