Revision: 7857
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7857&view=rev
Author:   robotos
Date:     2009-06-18 13:04:08 +0000 (Thu, 18 Jun 2009)

Log Message:
-----------
Check objects on exit code paths. Move check for existance of file from C to 
C++.  

Modified Paths:
--------------
    code/gazebo/trunk/server/GazeboConfig.cc
    code/gazebo/trunk/server/Simulator.cc
    code/gazebo/trunk/server/World.cc
    code/gazebo/trunk/server/XMLConfig.cc
    code/gazebo/trunk/server/main.cc

Modified: code/gazebo/trunk/server/GazeboConfig.cc
===================================================================
--- code/gazebo/trunk/server/GazeboConfig.cc    2009-06-18 11:28:09 UTC (rev 
7856)
+++ code/gazebo/trunk/server/GazeboConfig.cc    2009-06-18 13:04:08 UTC (rev 
7857)
@@ -88,7 +88,7 @@
     this->gazeboPaths.push_back(str.substr(pos1,str.size()-pos1));
   }
 
-  if (cfgFile)
+  if (cfgFile.is_open())
   {
     XMLConfig rc;
     XMLConfigNode *node;

Modified: code/gazebo/trunk/server/Simulator.cc
===================================================================
--- code/gazebo/trunk/server/Simulator.cc       2009-06-18 11:28:09 UTC (rev 
7856)
+++ code/gazebo/trunk/server/Simulator.cc       2009-06-18 13:04:08 UTC (rev 
7857)
@@ -241,6 +241,7 @@
   }
 
   this->loaded=true;
+
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -259,6 +260,9 @@
     gzthrow("Failed to Initialize the World\n"  << e);
   }
 
+  // This is not a debug line. This is useful for external programs that 
+  // launch Gazebo and wait till it is ready   
+  std::cout << "Gazebo successfully initialized" << std::endl;
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/World.cc
===================================================================
--- code/gazebo/trunk/server/World.cc   2009-06-18 11:28:09 UTC (rev 7856)
+++ code/gazebo/trunk/server/World.cc   2009-06-18 13:04:08 UTC (rev 7857)
@@ -294,12 +294,14 @@
     (*miter)->Fini();
   }
 
-  this->physicsEngine->Fini();
+  if (this->physicsEngine)
+    this->physicsEngine->Fini();
 
   // Done with the external interface
   try
   {
-    this->simIface->Destroy();
+    if (this->simIface)
+      this->simIface->Destroy();
   }
   catch (std::string e)
   { 
@@ -308,7 +310,8 @@
 
   try
   {
-    this->server->Fini();
+    if (this->server)
+      this->server->Fini();
   }
   catch (std::string e)
   {

Modified: code/gazebo/trunk/server/XMLConfig.cc
===================================================================
--- code/gazebo/trunk/server/XMLConfig.cc       2009-06-18 11:28:09 UTC (rev 
7856)
+++ code/gazebo/trunk/server/XMLConfig.cc       2009-06-18 13:04:08 UTC (rev 
7857)
@@ -29,6 +29,7 @@
 #include <math.h>
 #include <string.h>
 #include <iostream>
+#include <fstream>
 #include <sstream>
 
 #include <libxml/xinclude.h>
@@ -67,6 +68,14 @@
 {
   this->filename = filename;
 
+  std::ifstream fin;
+  fin.open(this->filename.c_str(), std::ios::in);
+  if( !fin.is_open() )
+  {
+    gzthrow( "The world file can not be opened, check path and permissions" );
+  }
+  fin.close();
+
   // Enable line numbering
   xmlLineNumbersDefault( 1 );
 

Modified: code/gazebo/trunk/server/main.cc
===================================================================
--- code/gazebo/trunk/server/main.cc    2009-06-18 11:28:09 UTC (rev 7856)
+++ code/gazebo/trunk/server/main.cc    2009-06-18 13:04:08 UTC (rev 7857)
@@ -233,18 +233,6 @@
 
   // Get the world file name
   worldFileName = argv[0];
-  tmpFile = fopen(worldFileName, "r");
-
-  if (tmpFile == NULL)
-  {
-    char tmpStr[256];
-    sprintf(tmpStr, "WorldFile [%s]", worldFileName);
-
-    perror(tmpStr);
-    return  -1;
-  }
-  fclose(tmpFile);
-
   return 0;
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to