[pan2: 94/268] fixed bug that caused the parts number not to update



commit b7517ca84a15ffee7a47d4a8a31b16572b0598c0
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Wed Jun 29 16:02:58 2011 +0200

    fixed bug that caused the parts number not to update

 pan/gui/post-ui.cc |   13 ++++++++++---
 pan/gui/post-ui.h  |    2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index b087768..9b6d333 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -2616,7 +2616,7 @@ PostUI :: select_encode (GtkAction* a)
     foreach(tasks_t, tasks, it)
     {
       const char* f = (*it)->filename().c_str();
-      int total(get_total_lines (f,*it));
+      int total(get_total_parts (f,*it));
 
       (*it)->_encode_mode = tmp;
       (*it)->_total_parts = total;
@@ -2629,7 +2629,7 @@ PostUI :: select_encode (GtkAction* a)
 }
 
 int
-PostUI :: get_total_lines(const char* file, TaskUpload* it)
+PostUI :: get_total_parts(const char* file, TaskUpload* it)
 {
     struct stat sb;
     stat (file,&sb);
@@ -2691,7 +2691,14 @@ PostUI :: select_parts ()
   if (!_upload_ptr) return;
 
   int lpf = _prefs.get_int("upload-option-lpf",4000);
-  _total_parts = get_total_lines(_upload_ptr->_filename.c_str(), _upload_ptr);
+  int new_parts = get_total_parts(_upload_ptr->_filename.c_str(), _upload_ptr);
+  if (_total_parts != new_parts)
+  {
+    _upload_ptr->_wanted.clear();
+    for (int i=1;i<=new_parts;++i)
+      _upload_ptr->_wanted.insert(i);
+  }
+  _total_parts = new_parts;
 
   GtkWidget * w;
   GtkTreeIter iter;
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 1bf739c..5878566 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -245,7 +245,7 @@ namespace pan
       void generate_unique_id (StringView& mid, int cnt, std::string& s);
       MTRand mtrand;
 
-      int get_total_lines(const char* file, TaskUpload* it);
+      int get_total_parts(const char* file, TaskUpload* it);
 
     private:
       guint _draft_autosave_id;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]