From 33346f975d71a8f861920fd2e3c1e7c10ccc48fa Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 2 Mar 2006 07:32:24 +0000 Subject: [PATCH] PAL11562: the module name must be removed from list of modules (from combobox and toolbar) if it isn't accessible (not installed, etc) The new protected method "isLibExists" is added. It checks, if module library is situated in some folders. Under Linux, this list is value of LD_LIBRARY_PATH, under Windows it is value of PATH --- src/LightApp/LightApp_Application.cxx | 26 +++++++++++++++++++++++++- src/LightApp/LightApp_Application.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index c63f918bc..7e929f7b9 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -426,7 +426,7 @@ void LightApp_Application::createActions() for ( it = modList.begin(); it != modList.end(); ++it ) { - if ( (*it).isEmpty() ) + if ( !isLibExists( *it ) ) continue; QString iconName; @@ -1962,3 +1962,27 @@ void LightApp_Application::onRenameWindow() if( ok && !name.isEmpty() ) w->setCaption( name ); } + +bool LightApp_Application::isLibExists( const QString& moduleTitle ) const +{ + if( moduleTitle.isEmpty() ) + return false; + + QString lib = moduleLibrary( moduleTitle ); + QStringList paths; +#ifdef WIN32 + paths = QStringList::split( ";", ::getenv( "PATH" ) ); +#else + paths = QStringList::split( ":", ::getenv( "LD_LIBRARY_PATH" ) ); +#endif + + QStringList::const_iterator anIt = paths.begin(), aLast = paths.end(); + for( ; anIt!=aLast; anIt++ ) + { + QFileInfo inf( Qtx::addSlash( *anIt ) + lib ); + if( inf.exists() ) + return true; + } + return false; +} + diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 6af7ef767..42c26c669 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -170,6 +170,7 @@ protected: void moduleIconNames( QMap& ) const; void activateWindows(); + bool isLibExists( const QString& ) const; protected: typedef QMap ActionMap; -- 2.39.2