]> git.mxchange.org Git - flightgear.git/commitdiff
adapt to changes in sg_exception interface
authorTim Moore <timoore@redhat.com>
Tue, 16 Jun 2009 08:41:17 +0000 (10:41 +0200)
committerTim Moore <timoore@redhat.com>
Tue, 16 Jun 2009 09:46:47 +0000 (11:46 +0200)
sg_location now uses C strings. Also, change uses of sg_throwable to more
specific exceptions like sg_io_exception.

src/Cockpit/hud.cxx
src/FDM/YASim/proptest.cpp
src/FDM/YASim/yasim-test.cpp
src/GUI/gui_funcs.cxx
src/Input/input.cxx
src/Instrumentation/HUD/HUD.cxx
src/Instrumentation/instrument_mgr.cxx
src/Main/bootstrap.cxx
src/Main/fg_init.cxx

index e6903caabbdb287910d472112eaefee5586bfb58..f9b9f3a9749b9cac69fb896ef681d5ed2f79d22b 100644 (file)
@@ -261,9 +261,11 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
     }
 
     FGFontCache *fc = globals->get_fontcache();
-    HUD_Font = fc->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf"));
+    const char* fileName = fgGetString("/sim/hud/font/name", "Helvetica.txf");
+    HUD_Font = fc->getTexFont(fileName);
     if (!HUD_Font)
-        throw sg_throwable(string("/sim/hud/font/name is not a texture font"));
+        throw sg_io_exception("/sim/hud/font/name is not a texture font",
+                              sg_location(fileName));
 
     HUD_TextSize = fgGetFloat("/sim/hud/font/size", 10);
 
index 6db6183f7ef0262133607336d560fae21143ef6a..c10d592112404c8844ed35bbbffe592b19d9defc 100644 (file)
@@ -51,7 +51,7 @@ int main(int argc, char** argv)
         readXML(argv[1], fdm);
     } catch (const sg_exception &e) {
         printf("XML parse error: %s (%s)\n",
-               e.getFormattedMessage().c_str(), e.getOrigin().c_str());
+               e.getFormattedMessage().c_str(), e.getOrigin());
     }
 
     Airplane* airplane = fdm.getAirplane();
index 2fa6425267f2488eaaf3f5fe0926d8ee7ef36aa0..09588734183e24fdf6a1703bb4b1ade584616373 100644 (file)
@@ -85,7 +85,7 @@ int main(int argc, char** argv)
         readXML(file, *fdm);
     } catch (const sg_exception &e) {
         printf("XML parse error: %s (%s)\n",
-               e.getFormattedMessage().c_str(), e.getOrigin().c_str());
+               e.getFormattedMessage().c_str(), e.getOrigin());
     }
 
     // ... and run
index 1dc5db7a4df931cd9d335e11a72fd1e4f141c618..1d2ccfba8b5255de8cf8ff3821be3132242af04b 100644 (file)
@@ -141,7 +141,7 @@ void guiErrorMessage (const char *txt, const sg_throwable &throwable)
     string msg = txt;
     msg += '\n';
     msg += throwable.getFormattedMessage();
-    if (!throwable.getOrigin().empty()) {
+    if (!std::strlen(throwable.getOrigin()) != 0) {
         msg += "\n (reported by ";
         msg += throwable.getOrigin();
         msg += ')';
index 695a42610405ce9c44b3a9ae7a2626e0bc05369f..d281c3593985dd1f0cf895863ae2ad8120533cb8 100644 (file)
@@ -512,8 +512,8 @@ FGInput::_init_joystick ()
             << "\"\nUsing default: \"" << source << '"');
 
       } else {
-        throw sg_throwable(string("No joystick configuration file with "
-            "<name>default</name> entry found!"));
+        throw sg_exception(string("No joystick configuration file with <name>")
+                           + name + "</name> entry found!");
       }
 
       js_node = js_nodes->getChild("js", i, true);
index d199c3b30428bb8959e445f684fd4fcd64ac105e..65543dea3dd710a4749b6de15d95de598795754f 100644 (file)
@@ -127,11 +127,15 @@ HUD::~HUD()
 
 void HUD::init()
 {
+    const char* fontName = 0;
     _font_cache = globals->get_fontcache();
+    if (!_font) {
+        fontName = fgGetString("/sim/hud/font/name", "Helvetica.txf");
+        _font = _font_cache->getTexFont(fontName);
+    }
     if (!_font)
-        _font = _font_cache->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf"));
-    if (!_font)
-        throw sg_throwable(string("/sim/hud/font/name is not a texture font"));
+        throw sg_io_exception("/sim/hud/font/name is not a texture font",
+                              sg_location(fontName));
 
     _font_size = fgGetFloat("/sim/hud/font/size", 8);
     _font_renderer->setFont(_font);
index da82cce9529b2e35eb1999b9975f8e0888861340..21b2a47e770972120ce3152e3f3c989681d0c147 100644 (file)
@@ -70,9 +70,9 @@ FGInstrumentMgr::FGInstrumentMgr ()
             readProperties( config.str(), config_props );
 
             if ( !build() ) {
-                throw sg_throwable(string(
-                        "Detected an internal inconsistency in the instrumentation\n"
-                        "system specification file.  See earlier errors for details."));
+                throw sg_error(
+                    "Detected an internal inconsistency in the instrumentation\n"
+                    "system specification file.  See earlier errors for details.");
             }
         } catch (const sg_exception&) {
             SG_LOG( SG_ALL, SG_ALERT, "Failed to load instrumentation system model: "
index aa9c314a2e3f44c71c812f2477ae6712f0ad5098..dc0723f373fd899dd17ebc9a02b3dcb468e09b4c 100644 (file)
@@ -219,7 +219,7 @@ int main ( int argc, char **argv ) {
                             // logging, since logging may be
                             // disabled.
         cerr << "Fatal error: " << t.getFormattedMessage() << endl;
-        if (!t.getOrigin().empty())
+        if (std::strlen(t.getOrigin()) != 0)
             cerr << " (received from " << t.getOrigin() << ')' << endl;
 
     } catch (const string &s) {
index b602efdf3b7ff645cf79a8c3b09fd2081fe052da..7079f3d206fc8e95bd721d75ecf7afbffec93353 100644 (file)
@@ -1279,7 +1279,7 @@ void fgInitFDM() {
     } else if ( model == "yasim" ) {
         cur_fdm_state = new YASim( dt );
     } else {
-        throw sg_throwable(string("Unrecognized flight model '") + model
+        throw sg_exception(string("Unrecognized flight model '") + model
                + "', cannot init flight dynamics model.");
     }
 }