void PluginManager::slotLoadNextPlugin()
{
	if ( _kpmp->pluginsToLoad.isEmpty() )
	{
		if ( _kpmp->shutdownMode == PluginManagerPrivate::StartingUp )
		{
			_kpmp->shutdownMode = PluginManagerPrivate::Running;
			_kpmp->isAllPluginsLoaded = true;
			emit allPluginsLoaded();
		}
		return;
	}

	QString key = _kpmp->pluginsToLoad.pop();
	loadPluginInternal( key );

	// Schedule the next run unconditionally to avoid code duplication on the
	// allPluginsLoaded() signal's handling. This has the added benefit that
	// the signal is delayed one event loop, so the accounts are more likely
	// to be instantiated.
	QTimer::singleShot( 0, this, SLOT(slotLoadNextPlugin()) );
}
Esempio n. 2
0
Plugin * PluginManager::loadPlugin( const QString &_pluginId, PluginLoadMode mode /* = LoadSync */ )
{
    QString pluginId = _pluginId;

    // Try to find legacy code
    // FIXME: Find any cases causing this, remove them, and remove this too - Richard
    if ( pluginId.endsWith( QLatin1String( ".desktop" ) ) )
    {
        kWarning() << "Trying to use old-style API!" << endl << kBacktrace();
        pluginId = pluginId.remove( QRegExp( QLatin1String( ".desktop$" ) ) );
    }

    if ( mode == LoadSync )
    {
        return loadPluginInternal( pluginId );
    }
    else
    {
        _kpmp->pluginsToLoad.push( pluginId );
        QTimer::singleShot( 0, this, SLOT( slotLoadNextPlugin() ) );
        return 0L;
    }
}