Changeset 4873 for branches/erijo-dev

Show
Ignore:
Timestamp:
03/20/07 05:38:00 (21 months ago)
Author:
erijo
Message:

Don't keep libraries loaded if no plugins are used from it.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/erijo-dev/licq/src/plugin/pluginrepository.cpp

    r4869 r4873  
    4040void Licq::TPluginRepository::rebuildCache() 
    4141{ 
    42   // Remove all old factories 
    43   PluginFactories.clear(); 
     42  TPluginFactories factories; 
    4443 
    4544  for (TStringList::const_iterator path = PluginPaths.begin(); 
    4645       path != PluginPaths.end(); ++path) 
    4746  { 
    48     const unsigned int count = PluginLoader.loadPlugins(*path, &PluginFactories); 
     47    const unsigned int count = PluginLoader.loadPlugins(*path, &factories); 
    4948    Log->debug("Loaded %u plugin%s from %s", 
    5049               count, (count == 1 ? "" : "s"), path->c_str()); 
    5150  } 
    5251 
    53   // Clear the cache 
     52  // Remove old factories and clear cache 
     53  PluginFactories.clear(); 
    5454  std::for_each(PluginCache.begin(), PluginCache.end(), ObjectDeleter()); 
    5555 
    56   for (TPluginFactories::const_iterator factory = PluginFactories.begin(); 
    57        factory != PluginFactories.end(); ++factory) 
     56  for (TPluginFactories::const_iterator factory = factories.begin(); 
     57       factory != factories.end(); ++factory) 
    5858  { 
     59    bool factorySaved = false; 
    5960    const unsigned int count = (*factory)->getPluginCount(); 
    6061    for (unsigned int index = 0; index < count; ++index) 
     
    8384      } 
    8485 
     86      // Save factory if it hasn't already been saved. 
     87      if (!factorySaved) 
     88      { 
     89        PluginFactories.push_back(*factory); 
     90        factorySaved = true; 
     91      } 
     92 
     93      // Cache plugin 
    8594      PluginCache[entry->Information.Name] = entry; 
    8695    }