Esempio n. 1
0
/*----------------------------------------------------------------------------*/
bool Analyzer::addPlugin( const QString& file )
{
	if ( file.isEmpty() ) //nothing to load
		return false;

	PRINT_DEBUG ("Loading plugin: " << file);

	PluginLoader * loader = new PluginLoader( file );
	Q_ASSERT (loader);
	if (loader->isLoaded())
	{
		error( "Plugin already loaded!" );
		loader->unload();
		delete loader;
		return false;
	}
	
	const bool success = loader->init();
	
	if (!success)
	{
		error( "Plugin initialization failed!" );
		loader->unload();
		delete loader;
		return false;
	}

	mPlugins.append( loader );
	connect( loader, SIGNAL(destroyed( QObject* )),
		this, SLOT(removePlugin( QObject* )) );

	emit newPlugin( loader );

	return true;
}