]> git.mxchange.org Git - flightgear.git/commitdiff
fgpanel: fixed some error handling/setup issues
authorThorstenB <brehmt@gmail.com>
Fri, 30 Sep 2011 20:20:00 +0000 (22:20 +0200)
committerThorstenB <brehmt@gmail.com>
Fri, 30 Sep 2011 20:20:00 +0000 (22:20 +0200)
- Provide error message when fgdata path is missing.
- Exit game mode when closing/aborting program (show mouse cursor etc).
- Support absolute paths for "--panel" parameter.
- Don't crash when a font is missing.

utils/fgpanel/FGGLApplication.cxx
utils/fgpanel/FGPanelApplication.cxx
utils/fgpanel/panel.cxx

index b0f58d250b2d426255c26aa28e15a1c8d251981a..2783737d924d39e1b5d4e3044ac317ca252a6127 100644 (file)
@@ -56,6 +56,8 @@ FGGLApplication::FGGLApplication( const char * aName, int argc, char ** argv ) :
 
 FGGLApplication::~FGGLApplication()
 {
+    if (gameMode)
+        glutLeaveGameMode();
 }
 
 void FGGLApplication::DisplayCallback()
index b587004775ccce602eb37355db1a5c8767b9c8e9..cf4bbcca3c572738c6894e1395549916f03d0946 100644 (file)
@@ -90,6 +90,15 @@ FGPanelApplication::FGPanelApplication( int argc, char ** argv ) :
     throw exception();
   }
 
+  // see if we got a valid fgdata path
+  SGPath BaseCheck(ApplicationProperties::root);
+  BaseCheck.append("version");
+  if (!BaseCheck.exists())
+  {
+      cerr << "Missing base package. Use --fg-root=path_to_fgdata" << endl; 
+      throw exception();
+  }
+
   try {
     SGPath tpath = ApplicationProperties::GetRootPath( panelFilename.c_str() );
     readProperties( tpath.str(), ApplicationProperties::Properties );
@@ -284,8 +293,12 @@ double ApplicationProperties::getDouble( const char * name, double def )
   if( n == NULL ) return def;
   return n->getDoubleValue();
 }
+
 SGPath ApplicationProperties::GetRootPath( const char * sub )
 {
+  SGPath subpath( sub );
+  if ( subpath.isAbsolute() )
+    return subpath;
   SGPath path( ApplicationProperties::root );
   if( sub != NULL )
     path.append( sub );
index 70c40876b5f38475827f6fb86bc6cc8e13ea9d1e..06a6159dbf99c4dea80f84682243c366419d3f7e 100644 (file)
@@ -804,6 +804,11 @@ FGTextLayer::draw ()
     transform();
 
     text_renderer.setFont(ApplicationProperties::fontCache.getTexFont(_font_name.c_str()));
+    if (!text_renderer.getFont())
+    {
+        SG_LOG( SG_COCKPIT, SG_ALERT, "Missing font file: " << _font_name );
+        return;
+    }
 
     text_renderer.setPointSize(_pointSize);
     text_renderer.begin();