Index: branches/2.0-beta1/src/PacpusLib/ComponentManager.cpp
===================================================================
--- branches/2.0-beta1/src/PacpusLib/ComponentManager.cpp	(revision 141)
+++ branches/2.0-beta1/src/PacpusLib/ComponentManager.cpp	(revision 146)
@@ -27,8 +27,7 @@
 {
     LOG_TRACE("getInstance()");
-    LOG_TRACE("before:  mInstance = " << mInstance);
-
-    if (!mInstance)
-    {
+    LOG_TRACE("before: mInstance = " << mInstance);
+
+    if (!mInstance) {
         LOG_INFO("creating new instance...");
         mInstance = new ComponentManager();
@@ -36,5 +35,5 @@
     }
 
-    LOG_TRACE("after:   mInstance = " << mInstance);
+    LOG_TRACE("after : mInstance = " << mInstance);
     return mInstance;
 }
@@ -44,6 +43,8 @@
     LOG_TRACE("destroy");
 
+    LOG_TRACE("before: mInstance = " << mInstance);
     delete mInstance;
     mInstance = NULL;
+    LOG_TRACE("after : mInstance = " << mInstance);
 }
 
@@ -60,7 +61,7 @@
     LOG_TRACE("destructor");
 
-    QMutableMapIterator<ComponentMap::key_type, ComponentMap::mapped_type> it(componentMap_);
-    while (it.hasNext())
-        unRegisterComponent(it.next().key());
+    for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it) {
+        bool unregisteredSuccessfully = unregisterComponent(it.key());
+    }
 
     LOG_DEBUG("component manager was deleted");
@@ -83,10 +84,9 @@
 }
 
-bool ComponentManager::unRegisterComponentFactory(const QString& type)
-{
-    LOG_TRACE("unRegisterComponentFactory(type="<< type << ")");
-
-    if (!factoryMap_.contains(type))
-    {
+bool ComponentManager::unregisterComponentFactory(const QString& type)
+{
+    LOG_TRACE("unregisterComponentFactory(type="<< type << ")");
+
+    if (!factoryMap_.contains(type)) {
         LOG_WARN("cannot unregister component factory '" << type << "'. It was not registered");
         return false;
@@ -115,10 +115,9 @@
 }
 
-bool ComponentManager::unRegisterComponent(const QString& name)
-{
-    LOG_TRACE("unRegisterComponent(name="<< name << ")");
-
-    if (!componentMap_.contains(name))
-    {
+bool ComponentManager::unregisterComponent(const QString& name)
+{
+    LOG_TRACE("unregisterComponent(name="<< name << ")");
+
+    if (!componentMap_.contains(name)) {
         LOG_WARN("cannot unregister component '" << name << "'. It was not registered");
         return false;
@@ -126,6 +125,9 @@
 
     // FIXME: delete component
-    //delete componentMap_[name];
-    componentMap_.remove(name);
+    ComponentBase* component = componentMap_.value(name, NULL);
+    //delete component;
+
+    // FIXME: remove from map (causes segfault in QMap::qMapLessThanKey on Windows)
+    //componentMap_.remove(name);
     LOG_INFO("unregistered component '" << name << "'");
 
@@ -137,8 +139,8 @@
     LOG_TRACE("createComponent(type=" << type << ", " << "name="<< name << ")");
 
-    FactoryMap::iterator it = factoryMap_.find(type);
-    if (it != factoryMap_.end())
-    {
-        (*it)->addComponent(name);
+    if (factoryMap_.contains(type)) {
+        ComponentFactoryBase* factory = factoryMap_.value(type);
+        assert(factory);
+        factory->addComponent(name);
         return true;
     }
@@ -211,8 +213,10 @@
     {
         // Load the plugins containing the components
-        QStringList plugins = xmlTree_->getAllPlugins();
+        QStringList plugins = xmlTree_->getAllPluginsNames();
         Q_FOREACH (QString plugin, plugins) {
             if (!loadPlugin(plugin)) {
                 LOG_WARN("cannot load plugin '" << plugin << "'");
+            } else {
+                LOG_INFO("successfully loaded plugin '" << plugin << "'");
             }
         }
@@ -296,5 +300,4 @@
 
     for (int i = 0; i < connectionsNodeList.size(); ++i) {
-
         cfg.localCopy(connectionsNodeList.item(i).toElement());
         QString connectionInput = cfg.getConnectionInput();
@@ -303,5 +306,4 @@
         int connectionPriority = cfg.getConnectionPriority();
 
-
         //TODO set connection mode from string
 
@@ -309,5 +311,4 @@
         //InputInterfaceBase::NeverSkip;
         //InputInterfaceBase::TimeBounded;
-
 
         if (!createConnection(connectionOutput, connectionInput, connectionType,connectionPriority)) {
@@ -325,6 +326,7 @@
 
     bool result = true;
-    for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it )
+    for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it) {
         result &= start(it.key());
+    }
 
     return result;
@@ -355,10 +357,23 @@
 
     bool result = true;
-    for (ComponentMap::iterator it = componentMap_.begin(); it != componentMap_.end(); ++it)
-        result &= stop(it.key());
+    for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it) {
+        result &= stop(*it);
+    }
 
     return result;
 }
 
+bool ComponentManager::stop(ComponentBase* component) const
+{
+    if (!component) {
+        LOG_WARN("NULL component pointer");
+        return false;
+    }
+    if (!component->stopComponent()) {
+        return false;
+    }
+    return true;
+}
+
 bool ComponentManager::stop(const QString& componentName)
 {
@@ -366,6 +381,5 @@
 
     ComponentBase* component = getComponent(componentName);
-    if (!component)
-    {
+    if (!component) {
         LOG_WARN("cannot stop component '" << componentName << "'" << ". It does not exist");
         return false;
@@ -373,5 +387,5 @@
 
     LOG_INFO("stopping component '" << componentName << "'...");
-    if (!component->stopComponent()) {
+    if (!stop(component)) {
         LOG_WARN("cannot stop component '" << componentName << "'" << ". It can be already stopped");
     }
