]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsCache.C
remove more forms.h cruft
[lyx.git] / src / graphics / GraphicsCache.C
index a2bed25973dfa2751e63849a5eef36e09052df94..fe2de807c940174056b3a7564b71faff8be744c2 100644 (file)
@@ -1,10 +1,9 @@
-// -*- C++ -*-
 /* This file is part of
  * =================================================
  * 
  *          LyX, The Document Processor
  *          Copyright 1995 Matthias Ettrich.
- *          Copyright 1995-2000 The LyX Team.
+ *          Copyright 1995-2001 The LyX Team.
  *
  *          This file Copyright 2000 Baruch Even
  * ================================================= */
 
 #include "support/LAssert.h"
 
-GraphicsCache * GraphicsCache::singleton = 0;
-
-
-GraphicsCache * 
+GraphicsCache &
 GraphicsCache::getInstance()
 {
-       if (!singleton) {
-               singleton = new GraphicsCache;
-               Assert(singleton != 0);
-       }
-
+       static GraphicsCache singleton;
        return singleton;
 }
 
 
 GraphicsCache::~GraphicsCache()
 {
-       // The map elements should have already been eliminated.
-       Assert(cache.empty());
-       
-       delete singleton;
+       // All elements are destroyed by the shared_ptr's in the map.
 }
 
 
@@ -50,7 +39,7 @@ GraphicsCache::addFile(string const & filename)
        CacheType::iterator it = cache.find(filename);
        
        if (it != cache.end()) {
-               return (*it).second;
+               return it->second;
        }
        
        shared_ptr_item cacheItem(new GraphicsCacheItem(filename));