+2001-02-28 Baruch Even <baruch@ev-en.org>
+
+ * GraphicsCache.h:
+ * GraphicsCache.C: Changed the singleton pattern implementation, the
+ former version "leaked" in the sense that it was not deallocated at
+ program end.
+
2001-02-20 Baruch Even <baruch@ev-en.org>
* GraphicsCache.C: Changed to use shared_ptr<GraphicsCacheItem>
#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;
}
{
// The map elements should have already been eliminated.
Assert(cache.empty());
-
- delete singleton;
}
class GraphicsCache : public noncopyable {
public:
/// Get the instance of the class.
- static GraphicsCache * getInstance();
+ static GraphicsCache & getInstance();
+ /// Public destructor due to compiler warnings.
+ ~GraphicsCache();
typedef boost::shared_ptr<GraphicsCacheItem> shared_ptr_item;
/// Private c-tor so we can control how many objects are instantiated.
GraphicsCache() {}
- /// Private d-tor so that no-one will destroy us.
- ~GraphicsCache();
-
- /// Holder of the single instance of the class.
- static GraphicsCache * singleton;
///
typedef std::map<string, shared_ptr_item> CacheType;
///
+2001-02-28 Baruch Even <baruch@ev-en.org>
+
+ * insetgraphics.C (updateInset): Changed due to the change in
+ GraphicsCache.
+
2001-02-26 Juergen Vigna <jug@sad.it>
* insettext.C (SetFont): Set Undo only if we have selection (as it is
// dialog.
void InsetGraphics::updateInset() const
{
- GraphicsCache * gc = GraphicsCache::getInstance();
+ GraphicsCache & gc = GraphicsCache::getInstance();
boost::shared_ptr<GraphicsCacheItem> temp(0);
// We do it this way so that in the face of some error, we will still
// be in a valid state.
if (!params.filename.empty()) {
- temp = gc->addFile(params.filename);
+ temp = gc.addFile(params.filename);
}
// Mark the image as unloaded so that it gets updated.