[Orxonox-commit 1532] r6250 - code/branches/presentation2/src/libraries/util

rgrieder at orxonox.net rgrieder at orxonox.net
Sat Dec 5 14:23:21 CET 2009


Author: rgrieder
Date: 2009-12-05 14:23:21 +0100 (Sat, 05 Dec 2009)
New Revision: 6250

Modified:
   code/branches/presentation2/src/libraries/util/OutputHandler.cc
Log:
Fixed a pseudo memory leak.

Modified: code/branches/presentation2/src/libraries/util/OutputHandler.cc
===================================================================
--- code/branches/presentation2/src/libraries/util/OutputHandler.cc	2009-12-04 18:24:30 UTC (rev 6249)
+++ code/branches/presentation2/src/libraries/util/OutputHandler.cc	2009-12-05 13:23:21 UTC (rev 6250)
@@ -173,10 +173,13 @@
         //! Pushed the just written output to the internal array
         void outputChanged(int level)
         {
-            // Read ostringstream and store it
-            this->output_.push_back(std::make_pair(level, this->buffer_.str()));
-            // Clear content and flags
-            this->buffer_.str(std::string());
+            if (!this->buffer_.str().empty())
+            {
+                // Read ostringstream and store it
+                this->output_.push_back(std::make_pair(level, this->buffer_.str()));
+                // Clear content and flags
+                this->buffer_.str(std::string());
+            }
             this->buffer_.clear();
         }
 
@@ -213,7 +216,7 @@
         this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
         this->registerOutputListener(this->consoleWriter_);
 
-        this->output_  = new MemoryLogWriter();
+        this->output_ = new MemoryLogWriter();
         // We capture as much input as the listener with the highest level
         this->output_->softDebugLevel_ = getSoftDebugLevel();
         this->registerOutputListener(this->output_);
@@ -223,6 +226,7 @@
     OutputHandler::~OutputHandler()
     {
         delete this->logFile_;
+        delete this->consoleWriter_;
         delete this->output_;
     }
 




More information about the Orxonox-commit mailing list