[pan2/testing: 179/279] fix' segfaults andnd filters...



commit c2cd612afa900f689d2371be7e2a765c64d1ba53
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Tue Jul 19 20:33:55 2011 +0200

    fix' segfaults andnd filters...

 pan/data-impl/rules-filter.cc |    4 +++
 pan/gui/header-pane.cc        |   52 ++++++++++++++++++++++------------------
 pan/gui/header-pane.h         |    2 +-
 pan/gui/post-ui.cc            |    7 +++--
 4 files changed, 38 insertions(+), 27 deletions(-)
---
diff --git a/pan/data-impl/rules-filter.cc b/pan/data-impl/rules-filter.cc
index b7598cb..97ea757 100644
--- a/pan/data-impl/rules-filter.cc
+++ b/pan/data-impl/rules-filter.cc
@@ -32,6 +32,8 @@ void
 RulesFilter :: finalize (Data& data)
 {
 
+  std::cerr<<"finalize "<<_delete.size()<<std::endl;
+
   data.delete_articles (_delete);
   _delete.clear();
 
@@ -51,6 +53,8 @@ RulesFilter :: test_article ( Data        & data,
 {
 
   bool pass (article.score >= rules._lb && article.score <= rules._hb);
+  if (rules._hb >= 9999 && article.score >= rules._hb) pass = true;
+  if (rules._lb <= -9999 && article.score <= rules._lb) pass = true;
 
   switch (rules._type)
   {
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index 1c7bd50..9aabbd0 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -1025,17 +1025,27 @@ namespace
 
 }
 
+//{ N_("Disabled"),"never" },
+//{ N_("Only new (Score == 0)"),"new" },
+//{ N_("9999 or more"), "watched" },
+//{ N_("5000 to 9998"), "high" },
+//{ N_("1 to 4999"),    "medium" },
+//{ N_("-9998 to -1"),  "low" },
+//{ N_("-9999 or less"),"ignored" }};
+
 #define RANGE 4998
-int
+std::pair<int,int>
 HeaderPane :: get_int_from_rules_str(std::string val)
 {
-  if (val == "new") return 0;
-  if (val == "never") return 9999+RANGE+1;
-  if (val == "watched") return 9999;
-  if (val == "high") return 5000;
-  if (val == "medium") return 1;
-  if (val == "low") return -4999;
-  if (val == "ignored") return -9999;
+  std::pair<int,int> res;
+  if (val == "new")     { res.first = 0;      res.second = 0; }
+  if (val == "never")   { res.first = 10;     res.second = 5; } // inversed, so never true
+  if (val == "watched") { res.first = 9999;   res.second = 99999; }
+  if (val == "high")    { res.first = 5000;   res.second = 5000+RANGE; }
+  if (val == "medium")  { res.first = 1;      res.second = 1+RANGE; }
+  if (val == "low")     { res.first = -9998;  res.second = -1; }
+  if (val == "ignored") { res.first = -9999;  res.second = -99999; }
+  return res;
 }
 
 void
@@ -1052,28 +1062,24 @@ HeaderPane :: rebuild_rules (bool enable)
   r.set_type_aggregate_and ();
   RulesInfo tmp;
 
-  int backup (get_int_from_rules_str("never"));
-  int val_mark_read(get_int_from_rules_str(_prefs.get_string("rules-mark-read-value", "never")));
-  if (!enable) val_mark_read = backup;
-  int val_delete(get_int_from_rules_str(_prefs.get_string("rules-delete-value", "never")));
-  if (!enable) val_delete = backup;
-  int val_cache(get_int_from_rules_str(_prefs.get_string("rules-autocache-value", "never")));
-  if (!enable) val_cache = backup;
-  int val_dl(get_int_from_rules_str(_prefs.get_string("rules-auto-dl-value", "never")));
-  if (!enable) val_dl = backup;
-
-  tmp.set_type_mark_read_b (val_mark_read, val_mark_read == 0 ? 0 : val_mark_read+RANGE);
-  r._aggregates.push_back (tmp);
+  std::pair<int,int> res;
 
-  tmp.set_type_delete_b (val_delete, val_delete == 0 ? 0 : val_delete+RANGE);
+  res = get_int_from_rules_str(_prefs.get_string("rules-delete-value", "never"));
+  tmp.set_type_delete_b (res.first, res.second);
   r._aggregates.push_back (tmp);
 
-  tmp.set_type_autocache_b (val_cache, val_cache == 0 ? 0 : val_cache+RANGE);
+  res = get_int_from_rules_str(_prefs.get_string("rules-mark-read-value", "never"));
+  tmp.set_type_mark_read_b (res.first, res.second);
   r._aggregates.push_back (tmp);
 
-  tmp.set_type_dl_b (val_dl, val_dl == 0 ? 0 : val_dl+RANGE);
+  res = get_int_from_rules_str(_prefs.get_string("rules-autocache-value", "never"));
+  tmp.set_type_autocache_b (res.first, res.second);
   r._aggregates.push_back (tmp);
 
+  res = get_int_from_rules_str(_prefs.get_string("rules-auto-dl-value", "never"));
+  tmp.set_type_dl_b (res.first, res.second);
+   r._aggregates.push_back (tmp);
+
 }
 
 void
diff --git a/pan/gui/header-pane.h b/pan/gui/header-pane.h
index 37ccfcb..425e85d 100644
--- a/pan/gui/header-pane.h
+++ b/pan/gui/header-pane.h
@@ -305,7 +305,7 @@ namespace pan
     private:
       void rebuild_filter (const std::string&, int);
       void rebuild_rules (bool enable=false);
-      int get_int_from_rules_str(std::string val);
+      std::pair <int,int> get_int_from_rules_str(std::string val);
       void refresh_font ();
 
     public: // public so that anonymous namespace can reach -- don't call
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 1e094f8..8bd16f2 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1064,6 +1064,8 @@ PostUI :: maybe_post_message (GMimeMessage * message)
     _queue.add_task (_post_task, Queue::TOP);
   } else {
 
+    gtk_widget_hide (_root); // hide the main window, we still need the class' data
+
     // prepend header for xml file (if one was chosen)
     if (!_save_file.empty())
     {
@@ -1108,7 +1110,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
     f.total=1;
     TaskUpload::Needed n;
     n.mid = out;
-    TaskUpload * tmp = new TaskUpload("",profile.posting_server,_cache,a,f,new_message_from_ui(UPLOADING));
+    TaskUpload * tmp = new TaskUpload(a.subject.to_string(),profile.posting_server,_cache,a,f,new_message_from_ui(UPLOADING));
     tmp->_needed.insert(std::pair<int, TaskUpload::Needed>(1,n));
     tmp->_queue_pos = -1;
     _queue.add_task (tmp, Queue::BOTTOM);
@@ -1133,7 +1135,6 @@ PostUI :: maybe_post_message (GMimeMessage * message)
             std::string out;
             generate_unique_id(domain, *pit,out);
             n.mid = out;
-            std::cerr<<"rng "<<out<<std::endl;
             if (first_mid.empty()) first_mid = out;
         }
 
@@ -1152,7 +1153,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
       _queue.add_task (*it, Queue::BOTTOM);
       t->add_listener(this);
     }
-    gtk_widget_hide (_root); // hide the main window, we still need the class' data
+
   }
 
   /**



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