pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3702 - trunk/pingus/src/screen


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3702 - trunk/pingus/src/screen
Date: Mon, 7 Jul 2008 08:34:58 +0200

Author: grumbel
Date: 2008-07-07 08:34:57 +0200 (Mon, 07 Jul 2008)
New Revision: 3702

Modified:
   trunk/pingus/src/screen/screen_manager.cpp
   trunk/pingus/src/screen/screen_manager.hpp
Log:
Added some more auto_ptr, fixed bug in instance()

Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp  2008-07-07 05:22:25 UTC (rev 
3701)
+++ trunk/pingus/src/screen/screen_manager.cpp  2008-07-07 06:34:57 UTC (rev 
3702)
@@ -32,8 +32,7 @@
 ScreenManager* ScreenManager::instance_ = 0;
 
 ScreenManager::ScreenManager()
-  : display_gc(new DrawingContext()),
-    cursor(0)   
+  : display_gc(new DrawingContext())
 {  
   assert(instance_ == 0);
   instance_ = this;
@@ -47,12 +46,10 @@
   else
     input_controller = 
std::auto_ptr<Input::Controller>(input_manager->create_controller(Pathname(controller_file,
                                                                                
                   Pathname::SYSTEM_PATH)));
-
 }
 
 ScreenManager::~ScreenManager ()
 {
-  delete cursor;
   instance_ = 0;
 }
 
@@ -94,7 +91,7 @@
         }
       get_current_screen()->update(time_delta);
 
-      if (cursor)
+      if (cursor.get())
         cursor->update(time_delta);
 
       // Last screen has popped, so we are going to end here
@@ -165,12 +162,9 @@
 ScreenManager*
 ScreenManager::instance ()
 {
-  if (instance_)
-    return instance_;
-  else
-    return instance_ = new ScreenManager ();
+  return instance_;
 }
-
+
 void
 ScreenManager::push_screen (Screen* screen)
 {
@@ -186,7 +180,7 @@
 void
 ScreenManager::pop_screen ()
 {
-  assert (cached_action == CA_NONE || cached_action == CA_POP);
+  assert(cached_action == CA_NONE);
   cached_action = CA_POP;
 }
 
@@ -200,7 +194,7 @@
 void
 ScreenManager::replace_screen (Screen* screen)
 {
-  assert (cached_action == CA_NONE);
+  assert(cached_action == CA_NONE);
   cached_action = CA_REPLACE;
   replace_screen_arg = ScreenPtr(screen);
 }
@@ -312,19 +306,18 @@
 {
   if (v)
     {
-      if (!cursor)
+      if (!cursor.get())
         {
-          cursor = new Cursor("core/cursors/animcross");
+          cursor = std::auto_ptr<Cursor>(new Cursor("core/cursors/animcross"));
           cursor->show();
           SDL_ShowCursor(SDL_DISABLE);
         }
     }
   else
     {
-      if (cursor)
+      if (cursor.get())
         {
-          delete cursor;
-          cursor = 0;
+          cursor = std::auto_ptr<Cursor>();
           SDL_ShowCursor(SDL_ENABLE);
         }
     }
@@ -333,7 +326,7 @@
 bool
 ScreenManager::swcursor_visible()
 {
-  return cursor;
+  return cursor.get();
 }
 
 /* EOF */

Modified: trunk/pingus/src/screen/screen_manager.hpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.hpp  2008-07-07 05:22:25 UTC (rev 
3701)
+++ trunk/pingus/src/screen/screen_manager.hpp  2008-07-07 06:34:57 UTC (rev 
3702)
@@ -43,7 +43,7 @@
   std::auto_ptr<Input::Controller> input_controller;
 
   std::auto_ptr<DrawingContext> display_gc;
-  Cursor* cursor;
+  std::auto_ptr<Cursor> cursor;
 
   /** Screen stack (first is the screen, second is delete_screen,
       which tells if the screen should be deleted onces it got poped





reply via email to

[Prev in Thread] Current Thread [Next in Thread]