- // built some unique filename
- ostringstream os;
- os << "preview_";
- for (string::const_iterator it = data.begin(); it != data.end(); ++it)
- os << char('A' + (*it & 15)) << char('a' + (*it >> 4));
- string base = os.str();
- string dir = OnlyPath(lyx::tempName());
- string file = dir + base + ".lyxpreview";
-
- // everything is fine already
- if (loader_.filename() == file)
+ // the preview cache, maps contents to image loaders
+ typedef std::map<string, boost::shared_ptr<grfx::Loader> > cache_type;
+ static cache_type theCache;
+ static int theCounter = 0;
+
+ // set our loader corresponding to our current data
+ cache_type::const_iterator it = theCache.find(data);
+
+ // is this old data?
+ if (it != theCache.end()) {
+ // we have already a loader, connect to it anyway
+ //lyxerr << "### updatePreview(), old loader: " << loader_ << "\n";
+ loader_ = it->second.get();
+ loader_->statusChanged.connect
+ (boost::bind(&InsetFormula::statusChanged, this));