]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetExternal.cpp
Merge branch 'master' into biblatex2
[lyx.git] / src / insets / InsetExternal.cpp
index e208137940f6dce2cfe61bd40d4622276720fa24..6e0baff5d739556fb9437c5f78968c7606938389 100644 (file)
@@ -99,7 +99,8 @@ TempName::~TempName()
 TempName & TempName::operator=(TempName const & other)
 {
        if (this != &other) {
-               tempname_.removeFile();
+               if (!tempname_.empty())
+                       tempname_.removeFile();
                support::TempFile f("lyxextXXXXXX.tmp");
                f.setAutoRemove(false);
                tempname_ = f.name(); 
@@ -505,11 +506,10 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd,
 void InsetExternal::addToToc(DocIterator const & cpit, bool output_active,
                                                         UpdateType) const
 {
-       DocIterator pit = cpit;
-       pit.push_back(CursorSlice(const_cast<InsetExternal &>(*this)));
-       shared_ptr<Toc> toc = buffer().tocBackend().toc("external");
        docstring str = screenLabel(params_, buffer());
-       toc->push_back(TocItem(pit, 0, str, output_active));
+       TocBuilder & b = buffer().tocBackend().builder("external");
+       b.pushItem(cpit, str, output_active);
+       b.pop();
 }
 
 
@@ -828,10 +828,8 @@ void InsetExternal::validate(LaTeXFeatures & features) const
 
        external::TemplateManager & etm = external::TemplateManager::get();
 
-       it  = cit->second.preambleNames.begin();
-       end = cit->second.preambleNames.end();
-       for (; it != end; ++it) {
-               string const preamble = etm.getPreambleDefByName(*it);
+       for (string const & name : cit->second.preambleNames) {
+               docstring const preamble = etm.getPreambleDefByName(name);
                if (!preamble.empty())
                        features.addPreambleSnippet(preamble);
        }