pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2482 - in trunk/src: . display gui input/buttons worldmap


From: David Philippi at BerliOS
Subject: [Pingus-CVS] r2482 - in trunk/src: . display gui input/buttons worldmap
Date: Fri, 4 Nov 2005 16:31:44 +0100

Author: torangan
Date: 2005-11-04 16:31:35 +0100 (Fri, 04 Nov 2005)
New Revision: 2482

Modified:
   trunk/src/console.cxx
   trunk/src/console.hxx
   trunk/src/credits.cxx
   trunk/src/display/drawing_context.cxx
   trunk/src/display/drawing_context.hxx
   trunk/src/fonts.cxx
   trunk/src/fps_counter.cxx
   trunk/src/fps_counter.hxx
   trunk/src/gui/screen_manager.cxx
   trunk/src/input/buttons/mouse_button.cxx
   trunk/src/pingu_action_factory.cxx
   trunk/src/pingus_main.cxx
   trunk/src/pingus_menu_manager.cxx
   trunk/src/playfield.cxx
   trunk/src/resource.cxx
   trunk/src/savegame_manager.cxx
   trunk/src/world.cxx
   trunk/src/world.hxx
   trunk/src/worldmap/manager.cxx
   trunk/src/worldobj_factory.cxx
Log:
patch to fix a segfault on exit in Windows

Modified: trunk/src/console.cxx
===================================================================
--- trunk/src/console.cxx       2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/console.cxx       2005-11-04 15:31:35 UTC (rev 2482)
@@ -150,7 +150,15 @@
   is_init = true;
 }
 
+// Unload any ClanLib objects that might linger around after we
+// destroy the graphics context
 void
+Console::deinit()
+{
+       font = CL_Font();
+}
+
+void
 Console::draw()
 {
   assert(is_init);

Modified: trunk/src/console.hxx
===================================================================
--- trunk/src/console.hxx       2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/console.hxx       2005-11-04 15:31:35 UTC (rev 2482)
@@ -77,7 +77,12 @@
   Console ();
   virtual ~Console();
 
+       /** Load any gfx or objects that we might need */
   void init();
+
+       /** Unload all gfx and objects */
+       void deinit();
+
   virtual void on_event();
 
   /** Sets the number of lines, which are displayed

Modified: trunk/src/credits.cxx
===================================================================
--- trunk/src/credits.cxx       2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/credits.cxx       2005-11-04 15:31:35 UTC (rev 2482)
@@ -279,6 +279,7 @@
 Credits::deinit()
 {
   delete instance_;
+       instance_ = 0;
 }
 
 void

Modified: trunk/src/display/drawing_context.cxx
===================================================================
--- trunk/src/display/drawing_context.cxx       2005-11-03 12:21:41 UTC (rev 
2481)
+++ trunk/src/display/drawing_context.cxx       2005-11-04 15:31:35 UTC (rev 
2482)
@@ -196,6 +196,12 @@
   translate_stack.push_back(CL_Pointf(0, 0));
 }
 
+DrawingContext::~DrawingContext()
+{
+  if (drawingrequests.size() > 0) 
+               clear();
+}
+
 void
 DrawingContext::render(CL_GraphicContext* gc)
 {

Modified: trunk/src/display/drawing_context.hxx
===================================================================
--- trunk/src/display/drawing_context.hxx       2005-11-03 12:21:41 UTC (rev 
2481)
+++ trunk/src/display/drawing_context.hxx       2005-11-04 15:31:35 UTC (rev 
2482)
@@ -48,6 +48,7 @@
 
 public:
   DrawingContext();
+       virtual ~DrawingContext();
 
   /** Draws everything in the drawing context to the screen */
   void render(CL_GraphicContext* gc);

Modified: trunk/src/fonts.cxx
===================================================================
--- trunk/src/fonts.cxx 2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/fonts.cxx 2005-11-04 15:31:35 UTC (rev 2482)
@@ -59,7 +59,20 @@
   lcd          = Resource::load_font("fonts/courier_small" + std::string(".") 
+ encoding); // PingusResource::load_font("Fonts/numbers", "fonts");
 }
 
-void deinit () {}
+void deinit () 
+{
+       chalk_large  = CL_Font();
+  chalk_normal = CL_Font();
+  chalk_small  = CL_Font();
+  pingus_small = CL_Font();
+  pingus_small_fix_num = CL_Font();
+  pingus_large = CL_Font();
+  courier_small = CL_Font();
+  xterm = CL_Font();
+  smallfont = CL_Font();
+  smallfont_h = CL_Font();
+  lcd = CL_Font();
+}
 
 } // namespace Fonts
 } // namespace Pingus

Modified: trunk/src/fps_counter.cxx
===================================================================
--- trunk/src/fps_counter.cxx   2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/fps_counter.cxx   2005-11-04 15:31:35 UTC (rev 2482)
@@ -35,6 +35,7 @@
 
 FPSCounter::~FPSCounter()
 {
+       font = CL_Font();
 }
 
 // We are not initialising the fpscounter in the constructor, 'cause
@@ -49,6 +50,13 @@
   fps_count = 0;
 }
 
+// Get rid of any ClanLib objects that might want to linger after
+// we unload all of our resources.
+void FPSCounter::deinit()
+{
+       font = CL_Font();
+}
+
 void
 FPSCounter::on_event()
 {

Modified: trunk/src/fps_counter.hxx
===================================================================
--- trunk/src/fps_counter.hxx   2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/fps_counter.hxx   2005-11-04 15:31:35 UTC (rev 2482)
@@ -62,6 +62,9 @@
   /** Load all the gfx and fonts... */
   void init();
 
+       /** Unload gfx and fonts... */
+       void deinit();
+
 private:
   FPSCounter (const FPSCounter&);
   FPSCounter& operator= (const FPSCounter&);

Modified: trunk/src/gui/screen_manager.cxx
===================================================================
--- trunk/src/gui/screen_manager.cxx    2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/gui/screen_manager.cxx    2005-11-04 15:31:35 UTC (rev 2482)
@@ -49,6 +49,7 @@
 
 ScreenManager::~ScreenManager ()
 {
+       delete display_gc;
 }
 
 void
@@ -286,6 +287,7 @@
 ScreenManager::deinit()
 {
   delete instance_;
+       instance_ = 0;
 }
 
 } // namespace Pingus

Modified: trunk/src/input/buttons/mouse_button.cxx
===================================================================
--- trunk/src/input/buttons/mouse_button.cxx    2005-11-03 12:21:41 UTC (rev 
2481)
+++ trunk/src/input/buttons/mouse_button.cxx    2005-11-04 15:31:35 UTC (rev 
2482)
@@ -34,10 +34,6 @@
     button_release_slot(CL_Mouse::sig_key_up().connect(this, 
&Input::Buttons::MouseButton::release_handler)),
     pressed(false)
 {
-  if (CL_Mouse::get_device().get_button_count() != -1 
-      && button > CL_Mouse::get_device().get_button_count())
-    PingusError::raise("MouseButton: Invalid button: " + CL_String::to(button) 
-                       + ", must be smaller than " + 
CL_String::to(CL_Mouse::get_device().get_button_count()));
 }
 
 void

Modified: trunk/src/pingu_action_factory.cxx
===================================================================
--- trunk/src/pingu_action_factory.cxx  2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/pingu_action_factory.cxx  2005-11-04 15:31:35 UTC (rev 2482)
@@ -91,6 +91,7 @@
 PinguActionFactory::deinit()
 {
   delete instance_;
+       instance_ = 0;
 }
 
 void

Modified: trunk/src/pingus_main.cxx
===================================================================
--- trunk/src/pingus_main.cxx   2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/pingus_main.cxx   2005-11-04 15:31:35 UTC (rev 2482)
@@ -870,12 +870,13 @@
 {
   CL_SetupCore::deinit();
   CL_SetupGUI::deinit ();
-  CL_SetupDisplay::deinit ();
 
   if (use_opengl)
     CL_SetupGL::deinit();
   else
     CL_SetupSDL::deinit();
+
+  CL_SetupDisplay::deinit ();
 }
 
 void
@@ -900,6 +901,10 @@
 void
 PingusMain::deinit_pingus()
 {
+       fps_counter.deinit();
+       console.deinit();
+
+       Fonts::deinit();
   Credits::deinit();
   PinguActionFactory::deinit();
   Sound::PingusSound::deinit();
@@ -907,10 +912,9 @@
   WorldObjFactory::deinit();
   WorldMapNS::WorldMapManager::deinit();
   ScreenManager::deinit();
-  Fonts::deinit();
-  Resource::deinit();
   StatManager::deinit();
   SavegameManager::deinit();
+  Resource::deinit();
 }
 
 } // namespace Pingus

Modified: trunk/src/pingus_menu_manager.cxx
===================================================================
--- trunk/src/pingus_menu_manager.cxx   2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/pingus_menu_manager.cxx   2005-11-04 15:31:35 UTC (rev 2482)
@@ -43,8 +43,9 @@
 {
   background.draw (gc);
 
-  gc.draw_fillrect(0, CL_Display::get_height () - 22,
-                   CL_Display::get_width (), CL_Display::get_height (),
+  gc.draw_fillrect(0.0, static_cast<float>(CL_Display::get_height () - 22),
+                   static_cast<float>(CL_Display::get_width ()),
+                                                                        
static_cast<float>(CL_Display::get_height ()),
                    CL_Color(0, 0, 0, 255));
 
   for (MenuStackIter i = menu_stack.begin (); i != menu_stack.end (); ++i)
@@ -57,11 +58,6 @@
 PingusMenuManager::update (const GameDelta& delta)
 {
   background.update (delta.get_time ());
-  // We copy the menu_stack so that we don't invalidate our
-  // iterators when menu's are removed/added in update()
-  //std::vector<PingusSubMenu *> tmp_menu_stack = menu_stack;
-  /*for (MenuStackIter i = tmp_menu_stack.begin (); i != tmp_menu_stack.end 
(); ++i)
-    (*i)->update (delta);*/
   menu_stack.back()->update (delta);
 }
 

Modified: trunk/src/playfield.cxx
===================================================================
--- trunk/src/playfield.cxx     2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/playfield.cxx     2005-11-04 15:31:35 UTC (rev 2482)
@@ -87,6 +87,7 @@
 
 Playfield::~Playfield()
 {
+       delete scene_context;
 }
 
 void

Modified: trunk/src/resource.cxx
===================================================================
--- trunk/src/resource.cxx      2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/resource.cxx      2005-11-04 15:31:35 UTC (rev 2482)
@@ -72,6 +72,7 @@
 void
 Resource::deinit()
 {
+       cleanup();
   surface_map.clear();
 }
 
@@ -287,37 +288,20 @@
 void
 Resource::cleanup ()
 {
-#ifdef CLANLIB_0_6
-  pout(PINGUS_DEBUG_RESOURCES) << "Resource::cleanup ()" << std::endl;
-
-  for (std::map<ResDescriptor, CL_Surface>::iterator i = surface_map.begin ();
-       i != surface_map.end (); ++i)
-    {
-      pout(PINGUS_DEBUG_RESOURCES) << "XXXX Lookat Resource : " << i->first
-                                   << " => " << i->second.get_reference_count 
() << std::endl;
-      if (i->first.type == ResDescriptor::RD_FILE
-         && i->second.get_reference_count () == 1)
+       CL_Resource res;
+       std::vector<std::string> resources = resmgr.get_all_resources();
+       for (std::vector<std::string>::iterator i = resources.begin(); i != 
resources.end(); i++)
        {
-          // FIXME:
-         //pout(PINGUS_DEBUG_RESOURCES) << "XXX Releasing File: " << i->first
-          //                             << " => " << 
i->second.get_reference_count () << std::endl;
-         //surface_map.erase(i);
+               res = resmgr.get_resource(*i);
+               while (res.get_reference_count() > 0)
+                       res.unload();
        }
-      else if (i->first.type == ResDescriptor::RD_RESOURCE
-              && i->second.get_reference_count () == 2)
-       {
-         pout(PINGUS_DEBUG_RESOURCES) << "XXX Releasing Resource : " << 
i->first
-                                      << " => " << 
i->second.get_reference_count () << std::endl;
-         surface_map.erase(i);
-       }
-    }
-#endif
 }
 
 unsigned int
 Resource::get_mtime (const std::string& res_name)
 {
-#ifdef CLANLIB_0_6
+       /*
   try
     {
       CL_ResourceManager res_man = Resource::get(datafile);
@@ -335,7 +319,6 @@
 #else
       // FIXME: Win32 mtime getter not implemented
       return 0;
-#endif
     }
   catch (CL_Error& err)
     {
@@ -343,6 +326,7 @@
       return 0;
     }
 #endif
+               */
   return 0;
 }
 

Modified: trunk/src/savegame_manager.cxx
===================================================================
--- trunk/src/savegame_manager.cxx      2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/savegame_manager.cxx      2005-11-04 15:31:35 UTC (rev 2482)
@@ -42,6 +42,7 @@
 void SavegameManager::deinit()
 {
        delete instance_;
+       instance_ = 0;
 }
 
 SavegameManager::SavegameManager(const std::string& arg_filename)

Modified: trunk/src/world.cxx
===================================================================
--- trunk/src/world.cxx 2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/world.cxx 2005-11-04 15:31:35 UTC (rev 2482)
@@ -107,14 +107,6 @@
   for (WorldObjIter it = world_obj.begin(); it != world_obj.end(); ++it) {
     delete *it;
   }
-       delete pingu_particle_holder;
-       delete rain_particle_holder;
-       delete smoke_particle_holder;
-       delete snow_particle_holder;
-       delete pingus;
-       delete action_holder;
-       delete colmap;
-       delete gfx_map;
   delete game_time;
 }
 

Modified: trunk/src/world.hxx
===================================================================
--- trunk/src/world.hxx 2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/world.hxx 2005-11-04 15:31:35 UTC (rev 2482)
@@ -29,7 +29,7 @@
 
 // Forward declarations
 class Vector;
-class ActionHolder;
+//class ActionHolder;
 class Entrance;
 class Exit;
 class Hotspot;
@@ -87,7 +87,7 @@
   PinguHolder*                    pingus;
 
   // Pointers which are references to objects from other classes
-  ActionHolder*   action_holder;
+  //ActionHolder*   action_holder;
   ColMap*         colmap;
 
   void    init_worldobjs (const PingusLevel& plf);

Modified: trunk/src/worldmap/manager.cxx
===================================================================
--- trunk/src/worldmap/manager.cxx      2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/worldmap/manager.cxx      2005-11-04 15:31:35 UTC (rev 2482)
@@ -344,6 +344,7 @@
 void WorldMapManager::deinit()
 {
        delete instance_;
+       instance_ = 0;
 }
 
 } // namespace WorldMapNS

Modified: trunk/src/worldobj_factory.cxx
===================================================================
--- trunk/src/worldobj_factory.cxx      2005-11-03 12:21:41 UTC (rev 2481)
+++ trunk/src/worldobj_factory.cxx      2005-11-04 15:31:35 UTC (rev 2482)
@@ -110,6 +110,7 @@
        {
                instance_->free_factories();
                delete instance_;
+               instance_ = 0;
        }
 }
 





reply via email to

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