Index: ../../SimGear/source/simgear/environment/metar.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/environment/metar.cxx,v
retrieving revision 1.7
diff -b -u -p -r1.7 metar.cxx
--- ../../SimGear/source/simgear/environment/metar.cxx  6 Oct 2005 09:45:36 
-0000       1.7
+++ ../../SimGear/source/simgear/environment/metar.cxx  25 Nov 2005 13:15:36 
-0000
@@ -107,7 +107,9 @@ SGMetar::SGMetar(const string& m, const
        scanType();
        if (!scanId() || !scanDate()) {
                delete[] _data;
-               throw sg_io_exception("metar data bogus (" + _url + ')');
+               static sg_io_exception E("metar data bogus ");
+               E.setLocation(_url);
+               throw E;
        }
        scanModifier();

@@ -133,7 +135,9 @@ SGMetar::SGMetar(const string& m, const

        if (_grpcount < 4) {
                delete[] _data;
-               throw sg_io_exception("metar data incomplete (" + _url + ')');
+               static sg_io_exception E("metar data incomplete ");
+               E.setLocation(_url);
+               throw E;
        }

        _url = "";
@@ -196,7 +200,9 @@ char *SGMetar::loadData(const char *id,
        sock->set_timeout(10000);
        if (!sock->open(SG_IO_OUT)) {
                delete sock;
-               throw sg_io_exception("cannot connect to " + host);
+               static sg_io_exception E("cannot connect to host ");
+               E.setLocation(host);
+               throw E;
        }

        string get = "GET ";
@@ -232,8 +238,11 @@ char *SGMetar::loadData(const char *id,

        char *b = buf;
        scanBoundary(&b);
-       if (*b == '<')
-               throw sg_io_exception("no metar data available from " + _url);
+       if (*b == '<') {
+               static sg_io_exception E("no metar data from the URL ");
+               E.setLocation(_url);
+               throw E;
+       }

        char *metar = new char[strlen(b) + 2];  // make room for " \0"
        strcpy(metar, b);
Index: ../../SimGear/source/simgear/props/condition.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/props/condition.cxx,v
retrieving revision 1.4
diff -b -u -p -r1.4 condition.cxx
--- ../../SimGear/source/simgear/props/condition.cxx    24 Sep 2003 17:19:23 
-0000      1.4
+++ ../../SimGear/source/simgear/props/condition.cxx    25 Nov 2005 13:15:38 
-0000
@@ -219,7 +219,8 @@ doComparison (const SGPropertyNode * lef
     break;
   }
   }
-  throw sg_exception("Unrecognized node type");
+  static sg_exception E("Unrecognized node type");
+  throw E;
   return 0;
 }

Index: ../../SimGear/source/simgear/props/props.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/props/props.cxx,v
retrieving revision 1.18
diff -b -u -p -r1.18 props.cxx
--- ../../SimGear/source/simgear/props/props.cxx        23 Oct 2005 14:04:42 
-0000      1.18
+++ ../../SimGear/source/simgear/props/props.cxx        25 Nov 2005 13:15:41 
-0000
@@ -103,6 +103,7 @@ parse_name (const string &path, int &i)
 {
   string name = "";
   int max = path.size();
+  static string E;

   if (path[i] == '.') {
     i++;
@@ -112,8 +113,10 @@ parse_name (const string &path, int &i)
     } else {
       name = ".";
     }
-    if (i < max && path[i] != '/')
-      throw string("Illegal character after " + name);
+    if (i < max && path[i] != '/') {
+      E = "Illegal character after " + name;
+      throw E;
+    }
   }

   else if (isalpha(path[i]) || path[i] == '_') {
@@ -129,15 +132,18 @@ parse_name (const string &path, int &i)
       } else if (path[i] == '[' || path[i] == '/') {
        break;
       } else {
-       throw string("name may contain only ._- and alphanumeric characters");
+       E = "name may contain only ._- and alphanumeric characters";
+       throw E;
       }
       i++;
     }
   }

   else {
-    if (name.size() == 0)
-      throw string("name must begin with alpha or '_'");
+    if (name.size() == 0) {
+      E = "name must begin with alpha or '_'";
+      throw E;
+    }
   }

   return name;
@@ -170,7 +176,8 @@ parse_index (const string &path, int &i)
     }
   }

-  throw string("unterminated index (looking for ']')");
+  static string E("unterminated index (looking for ']')");
+  throw E;
 }


@@ -291,8 +298,10 @@ find_node (SGPropertyNode * current,
                                // .. means parent directory
   else if (components[position].name == "..") {
     SGPropertyNode * parent = current->getParent();
-    if (parent == 0)
-      throw string("Attempt to move past root with '..'");
+    if (parent == 0) {
+      static string E("Attempt to move past root with '..'");
+      throw E;
+    }
     else
       return find_node(parent, components, position + 1, create);
   }
Index: ../../SimGear/source/simgear/props/props_io.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/props/props_io.cxx,v
retrieving revision 1.10
diff -b -u -p -r1.10 props_io.cxx
--- ../../SimGear/source/simgear/props/props_io.cxx     28 Jun 2005 11:19:41 
-0000      1.10
+++ ../../SimGear/source/simgear/props/props_io.cxx     25 Nov 2005 13:15:43 
-0000
@@ -122,11 +122,13 @@ checkFlag (const char * flag, bool defau
   else if (!strcmp(flag, "n"))
     return false;
   else {
+       static sg_io_exception E("", "SimGear Property Reader");
     string message = "Unrecognized flag value '";
     message += flag;
     message += '\'';
                                // FIXME: add location info
-    throw sg_io_exception(message, "SimGear Property Reader");
+       E.setMessage(message);
+       throw E;
   }
 }

@@ -137,10 +139,12 @@ PropsVisitor::startElement (const char *

   if (_level == 0) {
     if (strcmp(name, "PropertyList")) {
+       static sg_io_exception E("", "SimGear Property Reader");
       string message = "Root element name is ";
       message += name;
       message += "; expected PropertyList";
-      throw sg_io_exception(message, "SimGear Property Reader");
+       E.setMessage(message);
+       throw E;
     }

                                // Check for an include.
@@ -248,11 +252,13 @@ PropsVisitor::endElement (const char * n
     } else if (st.type == "unspecified") {
       ret = st.node->setUnspecifiedValue(_data.c_str());
     } else {
+       static sg_io_exception E("", "SimGear Property Reader");
       string message = "Unrecognized data type '";
       message += st.type;
       message += '\'';
                                // FIXME: add location information
-      throw sg_io_exception(message, "SimGear Property Reader");
+       E.setMessage(message);
+       throw E;
     }
     if (!ret)
       SG_LOG(SG_INPUT, SG_ALERT, "readProperties: Failed to set "
@@ -303,8 +309,11 @@ readProperties (istream &input, SGProper
 {
   PropsVisitor visitor(start_node, base);
   readXML(input, visitor, base);
-  if (visitor.hasException())
-    throw visitor.getException();
+  if (visitor.hasException()) {
+       static sg_io_exception Error;
+       Error = visitor.getException();
+       throw Error;
+  }
 }


@@ -320,8 +329,11 @@ readProperties (const string &file, SGPr
 {
   PropsVisitor visitor(start_node, file);
   readXML(file, visitor);
-  if (visitor.hasException())
-    throw visitor.getException();
+  if (visitor.hasException()) {
+       static sg_io_exception Error;
+       Error = visitor.getException();
+       throw Error;
+  }
 }


@@ -338,8 +350,11 @@ void readProperties (const char *buf, co
 {
   PropsVisitor visitor(start_node, "");
   readXML(buf, size, visitor);
-  if (visitor.hasException())
-    throw visitor.getException();
+  if (visitor.hasException()) {
+       static sg_io_exception Error;
+       Error = visitor.getException();
+       throw Error;
+  }
 }


@@ -526,7 +541,10 @@ writeProperties (const string &file, con
   if (output.good()) {
     writeProperties(output, start_node, write_all);
   } else {
-    throw sg_io_exception("Cannot open file", sg_location(file));
+       static sg_io_exception ex("", "SimGear writeProperties()");
+       ex.setMessage(strerror(errno)); // FIXME may be bogus with threads
+       ex.setLocation(sg_location(file));
+    throw ex;
   }
 }

@@ -585,9 +603,13 @@ copyProperties (const SGPropertyNode *in
     default:
       if (in->isAlias())
        break;
+      {
+       static sg_error E("", "SimGear Property Reader");
       string message = "Unknown internal SGPropertyNode type";
       message += in->getType();
-      throw sg_error(message, "SimGear Property Reader");
+       E.setMessage(message);
+       throw E;
+      }
     }
   }

Index: ../../SimGear/source/simgear/scene/material/matlib.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/material/matlib.cxx,v
retrieving revision 1.16
diff -b -u -p -r1.16 matlib.cxx
--- ../../SimGear/source/simgear/scene/material/matlib.cxx      23 Oct 2005 
13:47:46 -0000      1.16
+++ ../../SimGear/source/simgear/scene/material/matlib.cxx      25 Nov 2005 
13:15:47 -0000
@@ -185,7 +185,7 @@ bool SGMaterialLib::load( const string &
     } catch (const sg_exception &ex) {
         SG_LOG( SG_INPUT, SG_ALERT, "Error reading materials: "
                 << ex.getMessage() );
-        throw ex;
+        throw;
     }

     int nMaterials = materials.nChildren();
Index: ../../SimGear/source/simgear/scene/model/model.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/model/model.cxx,v
retrieving revision 1.35
diff -b -u -p -r1.35 model.cxx
--- ../../SimGear/source/simgear/scene/model/model.cxx  25 Sep 2005 07:44:50 
-0000      1.35
+++ ../../SimGear/source/simgear/scene/model/model.cxx  25 Nov 2005 13:15:47 
-0000
@@ -282,8 +282,11 @@ sgLoad3DModel( const string &fg_root, co

     ssgTexturePath((char *)texturepath.c_str());
     model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
-    if (model == 0)
-      throw sg_exception("Failed to load 3D model");
+    if (model == 0) {
+      static sg_io_exception E("Failed to load 3D model");
+      E.setLocation(modelpath.str());
+      throw E;
+    }
   }
                                 // Set up the alignment node
   ssgTransform * alignmainmodel = new ssgTransform;
Index: ../../SimGear/source/simgear/sound/sample_openal.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/sound/sample_openal.cxx,v
retrieving revision 1.23
diff -b -u -p -r1.23 sample_openal.cxx
--- ../../SimGear/source/simgear/sound/sample_openal.cxx        12 Nov 2005 
12:22:23 -0000      1.23
+++ ../../SimGear/source/simgear/sound/sample_openal.cxx        25 Nov 2005 
13:15:47 -0000
@@ -108,7 +108,8 @@ SGSoundSample::SGSoundSample( const char
     // create an OpenAL buffer handle
     alGenBuffers(1, &buffer);
     if ( print_openal_error("constructor (alGenBuffers)") ) {
-        throw sg_exception("Failed to gen OpenAL buffer.");
+       static sg_exception Error("Failed to gen OpenAL buffer.");
+        throw Error;
     }

     // Load the sample file
@@ -116,9 +117,11 @@ SGSoundSample::SGSoundSample( const char

   buffer = alutCreateBufferFromFile(samplepath.c_str());
   if (buffer == AL_NONE) {
+     static sg_io_exception Error("Failed to load wav file ");
      ALenum error = alutGetError ();
      print_openal_error("constructor (alutCreateBufferFromFile)");
-     throw sg_exception("Failed to load wav file: "+string(alutGetErrorString 
(error)));
+     Error.setLocation(string(alutGetErrorString (error)));
+     throw Error;
   }

 #else
@@ -131,7 +134,8 @@ SGSoundSample::SGSoundSample( const char
     alBufferData( buffer, format, data, size, freq );

     if ( print_openal_error("constructor (alBufferData)") ) {
-        throw sg_exception("Failed to buffer data.");
+        static sg_exception E("Failed to buffer data.");
+        throw E;
     }

     alutUnloadWAV( format, data, size, freq );
@@ -167,7 +171,8 @@ SGSoundSample::SGSoundSample( unsigned c
     // Load wav data into a buffer.
     alGenBuffers(1, &buffer);
     if ( print_openal_error("constructor (alGenBuffers)") ) {
-        throw sg_exception("Failed to gen buffer." );
+       static sg_exception Error("Failed to gen OpenAL buffer.");
+        throw Error;
     }

     format = AL_FORMAT_MONO8;
@@ -176,7 +181,8 @@ SGSoundSample::SGSoundSample( unsigned c

     alBufferData( buffer, format, _data, size, freq );
     if ( print_openal_error("constructor (alBufferData)") ) {
-        throw sg_exception("Failed to buffer data.");
+        static sg_exception E("Failed to buffer data.");
+        throw E;
     }

     print_openal_error("constructor return");
@@ -383,7 +389,9 @@ SGSoundSample::load_file(const char *pat
     ALfloat freqf;
     data = alutLoadMemoryFromFile(samplepath.c_str(), &format, &size, &freqf );
     if (data == NULL) {
-        throw sg_exception("Failed to load wav file.");
+       static sg_io_exception Error("Failed to load wav file ");
+       Error.setLocation(samplepath.str());
+       throw Error;
     }
     freq = (ALsizei)freqf;
 #else
@@ -395,7 +403,9 @@ SGSoundSample::load_file(const char *pat
                      &format, &data, &size, &freq, &loop );
 # endif
     if ( print_openal_error("constructor (alutLoadWAVFile)") ) {
-        throw sg_exception("Failed to load wav file.");
+       static sg_io_exception Error("Failed to load wav file ");
+       Error.setLocation(samplepath.str());
+        throw Error;
     }
 #endif

Index: ../../SimGear/source/simgear/structure/exception.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/structure/exception.cxx,v
retrieving revision 1.3
diff -b -u -p -r1.3 exception.cxx
--- ../../SimGear/source/simgear/structure/exception.cxx        19 Dec 2003 
17:44:30 -0000      1.3
+++ ../../SimGear/source/simgear/structure/exception.cxx        25 Nov 2005 
13:15:48 -0000
@@ -21,6 +21,23 @@ sg_location::sg_location ()
 {
 }

+sg_location::sg_location (const sg_location& other)
+  : _path(other._path),
+    _line(other._line),
+    _column(other._column),
+    _byte(other._byte)
+{
+}
+
+sg_location& sg_location::operator= (const sg_location& other)
+{
+       _path = other._path;
+       _line = other._line;
+       _column = other._column;
+       _byte = other._byte;
+       return *this;
+}
+
 sg_location::sg_location (const string &path, int line, int column)
   : _path(path),
     _line(line),
@@ -123,6 +140,19 @@ sg_throwable::sg_throwable (const string
 {
 }

+sg_throwable::sg_throwable (const sg_throwable& other)
+  : _message(other._message),
+    _origin(other._origin)
+{
+}
+
+sg_throwable& sg_throwable::operator= (const sg_throwable& other)
+{
+         _message = other._message;
+         _origin = other._origin;
+         return *this;
+}
+
 sg_throwable::~sg_throwable ()
 {
 }
@@ -193,6 +223,17 @@ sg_exception::sg_exception (const string
 {
 }

+sg_exception::sg_exception (const sg_exception& other)
+  : sg_throwable(other)
+{
+}
+
+sg_exception& sg_exception::operator= (const sg_exception& other)
+{
+       sg_throwable::operator=(other);
+       return *this;
+}
+
 sg_exception::~sg_exception ()
 {
 }
@@ -221,6 +262,19 @@ sg_io_exception::sg_io_exception (const
 {
 }

+sg_io_exception::sg_io_exception (const sg_io_exception& other)
+  : sg_exception(other),
+       _location(other._location)
+{
+}
+
+sg_io_exception& sg_io_exception::operator= (const sg_io_exception& other)
+{
+       sg_exception::operator=(other);
+       _location = other._location;
+       return *this;
+}
+
 sg_io_exception::~sg_io_exception ()
 {
 }
Index: ../../SimGear/source/simgear/structure/exception.hxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/structure/exception.hxx,v
retrieving revision 1.1
diff -b -u -p -r1.1 exception.hxx
--- ../../SimGear/source/simgear/structure/exception.hxx        24 Sep 2003 
17:19:23 -0000      1.1
+++ ../../SimGear/source/simgear/structure/exception.hxx        25 Nov 2005 
13:15:48 -0000
@@ -28,6 +28,8 @@ class sg_location
 public:
   sg_location ();
   sg_location (const string &path, int line = -1, int column = -1);
+  sg_location (const sg_location& other);
+  sg_location& operator=(const sg_location& other);
   virtual ~sg_location ();
   virtual const string &getPath () const;
   virtual void setPath (const string &path);
@@ -47,13 +49,15 @@ private:


 /**
- * Abstract base class for all throwables.
+ * Base class for all throwables.
  */
 class sg_throwable
 {
 public:
   sg_throwable ();
   sg_throwable (const string &message, const string &origin = "");
+  sg_throwable (const sg_throwable& other);
+  sg_throwable& operator= (const sg_throwable& other);
   virtual ~sg_throwable ();
   virtual const string &getMessage () const;
   virtual const string getFormattedMessage () const;
@@ -104,6 +108,8 @@ class sg_exception : public sg_throwable
 public:
   sg_exception ();
   sg_exception (const string &message, const string &origin = "");
+  sg_exception (const sg_exception& other);
+  sg_exception& operator= (const sg_exception& other);
   virtual ~sg_exception ();
 };

@@ -123,6 +129,8 @@ class sg_io_exception : public sg_except
 {
 public:
   sg_io_exception ();
+  sg_io_exception (const sg_io_exception& other);
+  sg_io_exception& operator= (const sg_io_exception& other);
   sg_io_exception (const string &message, const string &origin = "");
   sg_io_exception (const string &message, const sg_location &location,
                   const string &origin = "");
Index: ../../SimGear/source/simgear/structure/subsystem_mgr.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/structure/subsystem_mgr.cxx,v
retrieving revision 1.2
diff -b -u -p -r1.2 subsystem_mgr.cxx
--- ../../SimGear/source/simgear/structure/subsystem_mgr.cxx    11 Jun 2005 
08:39:26 -0000      1.2
+++ ../../SimGear/source/simgear/structure/subsystem_mgr.cxx    25 Nov 2005 
13:15:49 -0000
@@ -327,7 +327,8 @@ SGSubsystemMgr::add (const char * name,

     if (_subsystem_map.find(name) != _subsystem_map.end()) {
         SG_LOG(SG_GENERAL, SG_ALERT, "Adding duplicate subsystem " << name);
-        throw sg_exception("duplicate subsystem");
+        static sg_exception E("duplicate subsystem");
+        throw E;
     }
     _subsystem_map[name] = subsystem;
 }
Index: ../../SimGear/source/simgear/threads/SGQueue.hxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/threads/SGQueue.hxx,v
retrieving revision 1.5
diff -b -u -p -r1.5 SGQueue.hxx
--- ../../SimGear/source/simgear/threads/SGQueue.hxx    15 Sep 2004 15:28:58 
-0000      1.5
+++ ../../SimGear/source/simgear/threads/SGQueue.hxx    25 Nov 2005 13:15:50 
-0000
@@ -132,7 +132,7 @@ public:
      */
     virtual T pop() {
        SGGuard<SGLOCK> g(mutex);
-       //if (fifo.empty()) throw NoSuchElementException();
+       //if (fifo.empty()) throw NoSuchElementException(); // <- WRONG! THIS 
IS NOT JAVA!! DON'T THROW OBJECTS FROM THE STACK!!! --vassilii
        assert( ! this->fifo.empty() );
 //     if (fifo.empty())
 //     {
Index: ../../SimGear/source/simgear/xml/easyxml.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/xml/easyxml.cxx,v
retrieving revision 1.6
diff -b -u -p -r1.6 easyxml.cxx
--- ../../SimGear/source/simgear/xml/easyxml.cxx        15 Sep 2005 16:54:27 
-0000      1.6
+++ ../../SimGear/source/simgear/xml/easyxml.cxx        25 Nov 2005 13:15:50 
-0000
@@ -216,42 +216,37 @@ readXML (istream &input, XMLVisitor &vis
   visitor.startXML();

   char buf[16384];
+  static sg_io_exception ex("", "SimGear XML Parser");
+  try {
   while (!input.eof()) {
-
-                               // FIXME: get proper error string from system
     if (!input.good()) {
-      sg_io_exception ex ("Problem reading file",
-                           sg_location(path,
-                                       XML_GetCurrentLineNumber(parser),
-                                       XML_GetCurrentColumnNumber(parser)),
-                           "SimGear XML Parser");
-      XML_ParserFree(parser);
+                       ex.setMessage(strerror(errno)); // FIXME may be bogus 
with threads
       throw ex;
     }

     input.read(buf,16384);
     if (!XML_Parse(parser, buf, input.gcount(), false)) {
-      sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)),
-                           sg_location(path,
-                                       XML_GetCurrentLineNumber(parser),
-                                       XML_GetCurrentColumnNumber(parser)),
-                           "SimGear XML Parser");
-      XML_ParserFree(parser);
-      throw ex;
+                       throw parser;
     }
-
   }

                                // Verify end of document.
   if (!XML_Parse(parser, buf, 0, true)) {
-    sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)),
+               throw parser;
+         }
+  }
+  catch (XML_Parser&) { // catch the 'parser' from our lexical scope!
+       ex.setMessage(XML_ErrorString(XML_GetErrorCode(parser)));
+       ex.setLocation(
                          sg_location(path,
                                      XML_GetCurrentLineNumber(parser),
-                                     XML_GetCurrentColumnNumber(parser)),
-                         "SimGear XML Parser");
-    XML_ParserFree(parser);
+                               XML_GetCurrentColumnNumber(parser)));
     throw ex;
   }
+  catch (sg_io_exception&) {
+       XML_ParserFree(parser);
+       throw;
+  }

   XML_ParserFree(parser);
 }
@@ -263,16 +258,17 @@ readXML (const string &path, XMLVisitor
   if (input.good()) {
     try {
       readXML(input, visitor, path);
-    } catch (sg_io_exception &e) {
+    } catch (sg_io_exception &) {
       input.close();
-      throw e;
-    } catch (sg_throwable &t) {
+      throw;
+    } catch (sg_throwable &) {
       input.close();
-      throw t;
+      throw;
     }
   } else {
-    throw sg_io_exception("Failed to open file", sg_location(path),
-                         "SimGear XML Parser");
+         static sg_io_exception Error("Failed to open file", "SimGear XML 
Parser");
+         Error.setLocation( sg_location(path) );
+         throw Error;
   }
   input.close();
 }
@@ -289,11 +285,12 @@ readXML (const char *buf, const int size
   visitor.startXML();

   if (!XML_Parse(parser, buf, size, false)) {
-      sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)),
+         static sg_io_exception ex("", "SimGear XML Parser");
+      ex.setMessage(XML_ErrorString(XML_GetErrorCode(parser)));
+         ex.setLocation(
                            sg_location("In-memory XML buffer",
                                        XML_GetCurrentLineNumber(parser),
-                                       XML_GetCurrentColumnNumber(parser)),
-                           "SimGear XML Parser");
+                                       XML_GetCurrentColumnNumber(parser)));
       XML_ParserFree(parser);
       throw ex;
   }


_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to