]> Creatis software - cpPlugins.git/blobdiff - appli/examples/plugins/example_LoadPluginsFile.cxx
Bug smashed like a boss
[cpPlugins.git] / appli / examples / plugins / example_LoadPluginsFile.cxx
index 929a48cf0cd6b21acda4dec63e15259231c5bdaa..52af772a7dc20436eea02295454ae857a35d0e4f 100644 (file)
@@ -11,13 +11,16 @@ int main( int argc, char* argv[] )
   } // fi
 
   // Load interface
-  cpPlugins::Interface interface;
+  cpPlugins::Interface* interface = NULL;
   try
   {
-    interface.LoadPluginFile( argv[ 1 ] );
+    interface = new cpPlugins::Interface( );
+    interface->LoadPluginFile( argv[ 1 ] );
   }
   catch( std::exception& err )
   {
+    if( interface != NULL )
+      delete interface;
     std::cerr
       << "Error caught: "
       << err.what( )
@@ -27,13 +30,13 @@ int main( int argc, char* argv[] )
   } // yrt
 
   // Show loaded plugins
-  auto plugins = interface.GetPlugins( );
+  auto plugins = interface->GetPlugins( );
   for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt )
     std::cout << "Plugin: " << *pIt << std::endl;
   std::cout << std::endl;
 
   // Show loaded filters
-  auto filters = interface.GetFilters( );
+  auto filters = interface->GetFilters( );
   for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt )
   {
     std::cout << "Category: " << cIt->first << std::endl;
@@ -43,6 +46,9 @@ int main( int argc, char* argv[] )
         << std::endl;
 
   } // rof
+
+  // Free all and finish
+  delete interface;
   return( 0 );
 }