From be720b424a725bac3ad89b73d06763c37a8ea1f8 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Fri, 30 Sep 2011 22:20:00 +0200 Subject: [PATCH] fgpanel: fixed some error handling/setup issues - 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 | 2 ++ utils/fgpanel/FGPanelApplication.cxx | 13 +++++++++++++ utils/fgpanel/panel.cxx | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/utils/fgpanel/FGGLApplication.cxx b/utils/fgpanel/FGGLApplication.cxx index b0f58d250..2783737d9 100644 --- a/utils/fgpanel/FGGLApplication.cxx +++ b/utils/fgpanel/FGGLApplication.cxx @@ -56,6 +56,8 @@ FGGLApplication::FGGLApplication( const char * aName, int argc, char ** argv ) : FGGLApplication::~FGGLApplication() { + if (gameMode) + glutLeaveGameMode(); } void FGGLApplication::DisplayCallback() diff --git a/utils/fgpanel/FGPanelApplication.cxx b/utils/fgpanel/FGPanelApplication.cxx index b58700477..cf4bbcca3 100644 --- a/utils/fgpanel/FGPanelApplication.cxx +++ b/utils/fgpanel/FGPanelApplication.cxx @@ -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 ); diff --git a/utils/fgpanel/panel.cxx b/utils/fgpanel/panel.cxx index 70c40876b..06a6159db 100644 --- a/utils/fgpanel/panel.cxx +++ b/utils/fgpanel/panel.cxx @@ -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();