}
// Remove any previewed LaTeX snippets associated with this buffer.
- graphics::Previews::get().removeLoader(*this);
+ thePreviews()->removeLoader(*this);
delete d;
}
string const error_type = (format == "program")
? "Build" : bufferFormat();
+ ErrorList & error_list = d->errorLists[error_type];
string const ext = formats.extension(format);
FileName const tmp_result_file(changeExtension(filename, ext));
bool const success = theConverters().convert(this, FileName(filename),
tmp_result_file, FileName(absFileName()), backend_format, format,
- errorList(error_type));
+ error_list);
// Emit the signal to show the error list.
if (format != backend_format)
errors(error_type);
d->cursor_.setCurrentFont();
if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
- graphics::Previews::get().generateBufferPreviews(buffer_);
+ thePreviews()->generateBufferPreviews(buffer_);
}
#include "frontends/alert.h"
#include "frontends/Application.h"
+#include "graphics/Previews.h"
+
#include "support/lassert.h"
#include "support/debug.h"
#include "support/environment.h"
bool first_start;
/// the parsed command line batch command if any
vector<string> batch_commands;
+
+ ///
+ graphics::Previews preview_;
};
///
LyX::~LyX()
{
+ singleton_ = 0;
delete pimpl_;
}
return LyX::ref().getGuiMessages();
}
+
+graphics::Previews * thePreviews()
+{
+ return singleton_ ? 0 : &singleton_->pimpl_->preview_;
+}
+
} // namespace lyx
class LyXView;
}
+namespace graphics {
+class Previews;
+}
+
/// initial startup
class LyX {
public:
friend Movers & theSystemMovers();
friend frontend::Application * theApp();
friend KeyMap & theTopLevelKeymap();
+ friend graphics::Previews * thePreviews();
};
} // namespace lyx
}
-Previews & Previews::get()
-{
- static Previews singleton;
- return singleton;
+namespace {
+typedef boost::shared_ptr<PreviewLoader> PreviewLoaderPtr;
+///
+typedef map<Buffer const *, PreviewLoaderPtr> CacheType;
+///
+static CacheType preview_cache_;
}
-class Previews::Impl {
-public:
- ///
- typedef boost::shared_ptr<PreviewLoader> PreviewLoaderPtr;
- ///
- typedef map<Buffer const *, PreviewLoaderPtr> CacheType;
- ///
- CacheType cache;
-};
-
-
Previews::Previews()
- : pimpl_(new Impl)
{}
-Previews::~Previews()
-{
- delete pimpl_;
-}
-
-
PreviewLoader & Previews::loader(Buffer const & buffer) const
{
- Impl::CacheType::iterator it = pimpl_->cache.find(&buffer);
+ CacheType::iterator it = preview_cache_.find(&buffer);
- if (it == pimpl_->cache.end()) {
- Impl::PreviewLoaderPtr ptr(new PreviewLoader(buffer));
- pimpl_->cache[&buffer] = ptr;
+ if (it == preview_cache_.end()) {
+ PreviewLoaderPtr ptr(new PreviewLoader(buffer));
+ preview_cache_[&buffer] = ptr;
return *ptr.get();
}
void Previews::removeLoader(Buffer const & buffer) const
{
- Impl::CacheType::iterator it = pimpl_->cache.find(&buffer);
+ CacheType::iterator it = preview_cache_.find(&buffer);
- if (it != pimpl_->cache.end())
- pimpl_->cache.erase(it);
+ if (it != preview_cache_.end())
+ preview_cache_.erase(it);
}
/// a wrapper for lyxrc.preview
static LyXRC_PreviewStatus status();
- /// This is a singleton class. Get the instance.
- static Previews & get();
-
/** Returns the PreviewLoader for this buffer.
* Used by individual insets to update their own preview.
*/
void generateBufferPreviews(Buffer const & buffer) const;
private:
+ friend class LyX;
/// noncopyable
Previews(Previews const &);
void operator=(Previews const &);
* are instantiated.
*/
Previews();
- ~Previews();
-
- /// Use the Pimpl idiom to hide the internals.
- class Impl;
- /// The pointer never changes although *pimpl_'s contents may.
- Impl * const pimpl_;
};
} // namespace graphics
+
+/// This is a singleton class. Get the instance.
+/// Implemented in LyX.cpp.
+graphics::Previews * thePreviews();
+
} // namespace lyx
#endif // PREVIEWS_H