[Orxonox-commit 3311] r8000 - code/branches/usability/src/orxonox

rgrieder at orxonox.net rgrieder at orxonox.net
Mon Feb 28 05:15:15 CET 2011


Author: rgrieder
Date: 2011-02-28 05:15:14 +0100 (Mon, 28 Feb 2011)
New Revision: 8000

Modified:
   code/branches/usability/src/orxonox/ChatInputHandler.cc
   code/branches/usability/src/orxonox/ChatInputHandler.h
Log:
Destructors can sometimes be very useful for clean up ;)

Modified: code/branches/usability/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/branches/usability/src/orxonox/ChatInputHandler.cc	2011-02-28 04:05:02 UTC (rev 7999)
+++ code/branches/usability/src/orxonox/ChatInputHandler.cc	2011-02-28 04:15:14 UTC (rev 8000)
@@ -73,6 +73,13 @@
     this->inputState->setKeyHandler(this->inpbuf);
   }
 
+  ChatInputHandler::~ChatInputHandler()
+  {
+    /* Clean up */
+    InputManager::getInstance().destroyState("chatinput");
+    delete this->inpbuf;
+  }
+
   /* configure input buffer, sub for the constructor */
   void ChatInputHandler::configureInputBuffer()
   {
@@ -124,24 +131,21 @@
     // three loops: red tones, blue tones and green tones
     // reds
     for( i = 0; i < NumberOfColors/3; ++i )
-    { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
-      assert( this->text_colors[ i ] );
+    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
       green += 0.2f, blue += 0.2f;
     }
 
     // greens
     red = 0.5, green = 1, blue = 0.5;
     for( ; i < NumberOfColors*2/3; ++i )
-    { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
-      assert( this->text_colors[ i ] );
+    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
       red += 0.2f, blue += 0.2f;
     }
 
     // blues
     red = 0.5, green = 0.5, blue = 1;
     for( ; i < NumberOfColors; ++i )
-    { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
-      assert( this->text_colors[ i ] );
+    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
       red += 0.2f, green += 0.2f;
     }
   }
@@ -195,7 +199,7 @@
     hash = hash % this->NumberOfColors;
 
     /* set the color according to the hash */
-    tocolor->setTextColours( *(this->text_colors[ hash ]) );
+    tocolor->setTextColours( this->text_colors[ hash ] );
   }
 
   /* handle incoming chat */

Modified: code/branches/usability/src/orxonox/ChatInputHandler.h
===================================================================
--- code/branches/usability/src/orxonox/ChatInputHandler.h	2011-02-28 04:05:02 UTC (rev 7999)
+++ code/branches/usability/src/orxonox/ChatInputHandler.h	2011-02-28 04:15:14 UTC (rev 8000)
@@ -36,6 +36,7 @@
 #include <iostream>
 #include <cassert>
 #include <CEGUIForwardRefs.h>
+#include <CEGUIcolour.h>
 
 /* project includes */
 #include <OrxonoxPrereqs.h>
@@ -69,7 +70,7 @@
 
       /* colors for nickname coloring */
       static const int NumberOfColors = 10;
-      CEGUI::colour *text_colors[ NumberOfColors ];
+      CEGUI::colour text_colors[ NumberOfColors ];
 
       /** input state */
       InputState *inputState;
@@ -109,6 +110,7 @@
     public:
       /** constructor */
       ChatInputHandler();
+      ~ChatInputHandler();
       friend class Singleton<ChatInputHandler>;
 
       static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); }  // tolua_export




More information about the Orxonox-commit mailing list