}
-class FindFirst
+std::function <bool (SnippetPair const &)> FindFirst(string const & comp)
{
-public:
- FindFirst(string const & comp) : comp_(comp) {}
- bool operator()(SnippetPair const & sp) const { return sp.first == comp_; }
-private:
- string const comp_;
-};
+ return [&comp](SnippetPair const & sp) { return sp.first == comp; };
+}
/// Store info on a currently executing, forked process.
/// Remove any files left lying around and kill the forked process.
void stop() const;
- ///
- pid_t pid;
///
string command;
///
FileName metrics_file;
///
BitmapFile snippets;
+ ///
+ pid_t pid;
};
typedef map<pid_t, InProgress> InProgressProcesses;
///
QTimer * delay_refresh_;
///
+ Trackable trackable_;
+ ///
bool finished_generating_;
/// We don't own this
static lyx::Converter const * pconverter_;
- Trackable trackable_;
};
{
ostringstream os;
os << base_ << counter_++ << '.' << to_format_;
- string const file = os.str();
-
- return make_pair(snippet, FileName(file));
+ string const file_name = os.str();
+ return make_pair(snippet, FileName(file_name));
}
-
+
private:
string const & to_format_;
string const & base_;
InProgress::InProgress(string const & filename_base,
PendingSnippets const & pending,
string const & to_format)
- : pid(0),
- metrics_file(filename_base + ".metrics"),
- snippets(pending.size())
+ : metrics_file(filename_base + ".metrics"),
+ snippets(pending.size()), pid(0)
{
PendingSnippets::const_iterator pit = pending.begin();
PendingSnippets::const_iterator pend = pending.end();
{
font_scaling_factor_ = int(buffer_.fontScalingFactor());
if (theApp()) {
- fg_color_ = strtol(theApp()->hexName(foregroundColor()).c_str(), nullptr, 16);
- bg_color_ = strtol(theApp()->hexName(backgroundColor()).c_str(), nullptr, 16);
+ fg_color_ = convert(theApp()->hexName(foregroundColor()).c_str(), 16);
+ bg_color_ = convert(theApp()->hexName(backgroundColor()).c_str(), 16);
} else {
fg_color_ = 0x0;
bg_color_ = 0xffffff;
int fg = 0x0;
int bg = 0xffffff;
if (theApp()) {
- fg = strtol(theApp()->hexName(foregroundColor()).c_str(), nullptr, 16);
- bg = strtol(theApp()->hexName(backgroundColor()).c_str(), nullptr, 16);
+ fg = convert(theApp()->hexName(foregroundColor()).c_str(), 16);
+ bg = convert(theApp()->hexName(backgroundColor()).c_str(), 16);
}
if (font_scaling_factor_ != fs || fg_color_ != fg || bg_color_ != bg) {
// Schedule refresh of all previews on zoom or color changes.
// Don't try to access the cache until we are done.
if (delay_refresh_->isActive() || !finished_generating_)
return nullptr;
+
Cache::const_iterator it = cache_.find(latex_snippet);
return (it == cache_.end()) ? nullptr : it->second.get();
}
std::function<bool (InProgressProcess const &)> FindSnippet(string const & s)
{
- return [s](InProgressProcess const & process) {
+ return [&s](InProgressProcess const & process) {
BitmapFile const & snippets = process.second.snippets;
BitmapFile::const_iterator beg = snippets.begin();
BitmapFile::const_iterator end = snippets.end();
namespace {
std::function<void (InProgressProcess &)> EraseSnippet(string const & s) {
- return [s](InProgressProcess & process) {
+ return [&s](InProgressProcess & process) {
BitmapFile & snippets = process.second.snippets;
BitmapFile::iterator it = snippets.begin();
BitmapFile::iterator end = snippets.end();