Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / ZYppFactory.cc
index 03ea897..45fc1c2 100644 (file)
@@ -282,35 +282,14 @@ namespace zypp
 
   };
 
-  ///////////////////////////////////////////////////////////////////
   namespace
   {
-    static weak_ptr<ZYpp>              _theZYppInstance;
-    static scoped_ptr<ZYppGlobalLock>  _theGlobalLock;         // on/off in sync with _theZYppInstance
-
-    ZYppGlobalLock & globalLock()
+    static ZYppGlobalLock & globalLock()
     {
-      if ( !_theGlobalLock )
-       _theGlobalLock.reset( new ZYppGlobalLock );
-      return *_theGlobalLock;
+      static ZYppGlobalLock lock;
+      return lock;
     }
-  } //namespace
-  ///////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : ZYpp
-  //
-  ///////////////////////////////////////////////////////////////////
-
-  ZYpp::ZYpp( const Impl_Ptr & impl_r )
-  : _pimpl( impl_r )
-  {
-  }
-
-  ZYpp::~ZYpp()
-  {
-    _theGlobalLock.reset();
+    bool           _haveZYpp = false;
   }
 
   ///////////////////////////////////////////////////////////////////
@@ -334,12 +313,31 @@ namespace zypp
   //
   ///////////////////////////////////////////////////////////////////
 
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : ZYppFactory::instance
+  //   METHOD TYPE : ZYppFactory
+  //
   ZYppFactory ZYppFactory::instance()
-  { return ZYppFactory(); }
+  {
+    return ZYppFactory();
+  }
 
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : ZYppFactory::ZYppFactory
+  //   METHOD TYPE : Ctor
+  //
   ZYppFactory::ZYppFactory()
-  {}
+  {
 
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : ZYppFactory::~ZYppFactory
+  //   METHOD TYPE : Dtor
+  //
   ZYppFactory::~ZYppFactory()
   {}
 
@@ -347,7 +345,8 @@ namespace zypp
   //
   ZYpp::Ptr ZYppFactory::getZYpp() const
   {
-    ZYpp::Ptr _instance = _theZYppInstance.lock();
+    static ZYpp::Ptr _instance;
+
     if ( ! _instance )
     {
       if ( geteuid() != 0 )
@@ -388,6 +387,7 @@ namespace zypp
              }
            }
          }
+
        }
        if ( failed )
        {
@@ -400,11 +400,9 @@ namespace zypp
        }
       }
       // Here we go...
-      static ZYpp::Impl_Ptr _theImplInstance;  // for now created once
-      if ( !_theImplInstance )
-       _theImplInstance.reset( new ZYpp::Impl );
-      _instance.reset( new ZYpp( _theImplInstance ) );
-      _theZYppInstance = _instance;
+      _instance = new ZYpp( ZYpp::Impl_Ptr(new ZYpp::Impl) );
+      if ( _instance )
+        _haveZYpp = true;
     }
 
     return _instance;
@@ -413,7 +411,7 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
   //
   bool ZYppFactory::haveZYpp() const
-  { return !_theZYppInstance.expired(); }
+  { return _haveZYpp; }
 
   /******************************************************************
   **