Browse Source

- Fix crash when a torrent contains empty files

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

5
src/eventmanager.cpp

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

5
src/torrentfilesmodel.h

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

Loading…
Cancel
Save