[pan2] fix for iso c++ and struct deque



commit b1af29b364aacc9766b816b3a5c5da457cec4d98
Author: Heinrich Müller <heinrich mueller82 gmail com>
Date:   Fri Dec 20 22:29:02 2013 +0100

    fix for iso c++ and struct deque

 pan/general/log.cc |    6 +++++-
 pan/general/log.h  |    7 +++++--
 pan/gui/log-ui.cc  |   14 ++++++++------
 3 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/pan/general/log.cc b/pan/general/log.cc
index aba4177..402d855 100644
--- a/pan/general/log.cc
+++ b/pan/general/log.cc
@@ -61,7 +61,11 @@ Log :: add_entry(Entry& e, std::deque<Entry>& list)
   a.date = time(NULL);
   a.severity = e.severity;
   a.message = e.message;
-  a.messages = list;
+  foreach (std::deque<Entry>, list, it)
+  {
+    Entry* new_entry = new Entry(*it);
+    a.messages.push_back(new_entry);
+  }
   fire_entry_added (a);
 }
 
diff --git a/pan/general/log.h b/pan/general/log.h
index 2def9a6..7149548 100644
--- a/pan/general/log.h
+++ b/pan/general/log.h
@@ -25,6 +25,7 @@
 #include <string>
 #include <deque>
 #include <pan/general/singleton-template.h>
+#include <pan/general/macros.h>
 
 namespace pan
 {
@@ -50,10 +51,11 @@ namespace pan
       struct Entry {
         time_t date;
         Severity severity;
-        std::deque<Entry> messages;
+        std::deque<Entry*> messages;
         std::string message;
         bool is_child;
-        Entry() : is_child(false) { }
+        Entry() : is_child(false), severity(PAN_SEVERITY_INFO), date(0) { }
+        virtual ~Entry () { foreach (std::deque<Entry*>, messages, it) delete *it; }
       };
 
       void add_entry(Entry& e, std::deque<Entry>& list);
@@ -67,6 +69,7 @@ namespace pan
       };
 
       typedef std::deque<Entry> entries_t;
+      typedef std::deque<Entry*> entries_p;
 
     public:
       void add (Severity, const char *);
diff --git a/pan/gui/log-ui.cc b/pan/gui/log-ui.cc
index bef9446..8815e8f 100644
--- a/pan/gui/log-ui.cc
+++ b/pan/gui/log-ui.cc
@@ -61,13 +61,14 @@ namespace
        {
         GtkTreeIter child;
 
-        foreach_const (Log::entries_t, e.messages, lit)
+        foreach_const (Log::entries_p, e.messages, lit)
         {
+          Log::Entry entry(**lit);
           gtk_tree_store_prepend (myStore, &child, &iter );
           gtk_tree_store_set (myStore, &child,
                           COL_HIDDEN, "",
-                          COL_SEVERITY, (lit->severity & Log::PAN_SEVERITY_ERROR),
-                          COL_DATE, (unsigned long)lit->date,
+                          COL_SEVERITY, (entry.severity & Log::PAN_SEVERITY_ERROR),
+                          COL_DATE, (unsigned long)entry.date,
                           COL_MESSAGE, &*lit, -1);
         }
       }
@@ -157,13 +158,14 @@ namespace
                           COL_MESSAGE, &*it, -1);
       if (!it->messages.empty())
       {
-        foreach_const (Log::entries_t, it->messages, lit)
+        foreach_const (Log::entries_p, it->messages, lit)
         {
+          Log::Entry entry (**lit);
           gtk_tree_store_prepend (store, &child, &top );
           gtk_tree_store_set (store, &child,
                           COL_HIDDEN, "",
-                          COL_SEVERITY, (lit->severity & Log::PAN_SEVERITY_ERROR),
-                          COL_DATE, (unsigned long)lit->date,
+                          COL_SEVERITY, (entry.severity & Log::PAN_SEVERITY_ERROR),
+                          COL_DATE, (unsigned long)entry.date,
                           COL_MESSAGE, &*lit, -1);
         }
       }


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