]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetExternal.cpp
Squash some warnings.
[lyx.git] / src / insets / InsetExternal.cpp
index 8b0f00c5def651cb63c8faeadacd5fa322ee5679..5a7a07a8e3ba1af988d4c9a8b5f24986cd4fcab4 100644 (file)
@@ -69,13 +69,20 @@ namespace Alert = frontend::Alert;
 
 namespace external {
 
-TempName::TempName() : tempfile_(new support::TempFile("lyxextXXXXXX.tmp"))
+TempName::TempName()
 {
        // must have an extension for the converter code to work correctly.
+       support::TempFile f("lyxextXXXXXX.tmp");
+       // Let f go out of scope here and delete the file ourselves in
+       // ~TempName(), since otherwise external processes would not be able
+       // to use the file on windows (bug 9925). This is not as safe as
+       // keeping a support::TempFile member would be, but the best we can do.
+       f.setAutoRemove(false);
+       tempname_ = f.name();
 }
 
 
-TempName::TempName(TempName const & that) : tempfile_(0)
+TempName::TempName(TempName const & that)
 {
        *this = that;
 }
@@ -83,15 +90,17 @@ TempName::TempName(TempName const & that) : tempfile_(0)
 
 TempName::~TempName()
 {
-       delete tempfile_;
+       tempname_.removeFile();
 }
 
 
 TempName & TempName::operator=(TempName const & other)
 {
        if (this != &other) {
-               delete tempfile_;
-               tempfile_ = new support::TempFile("lyxextXXXXXX.tmp");
+               tempname_.removeFile();
+               support::TempFile f("lyxextXXXXXX.tmp");
+               f.setAutoRemove(false);
+               tempname_ = f.name(); 
        }
        return *this;
 }
@@ -99,7 +108,7 @@ TempName & TempName::operator=(TempName const & other)
 
 support::FileName TempName::operator()() const
 {
-       return tempfile_->name();
+       return tempname_;
 }
 
 } // namespace external
@@ -107,6 +116,7 @@ support::FileName TempName::operator()() const
 
 InsetExternalParams::InsetExternalParams()
        : display(true),
+         preview_mode(PREVIEW_OFF),
          lyxscale(defaultLyxScale),
          draft(false)
 {
@@ -366,6 +376,8 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
 
        if (lyxerr.debugging(Debug::EXTERNAL)) {
                lyxerr  << "InsetExternalParams::read:\n";
+               // false positive
+               // coverity[NEGATIVE_RETURNS]
                write(buffer, lyxerr);
        }
 
@@ -409,7 +421,7 @@ InsetExternal::InsetExternal(Buffer * buf)
 // Mouse hover is not copied and remains empty
 InsetExternal::InsetExternal(InsetExternal const & other)
        : Inset(other),
-         boost::signals::trackable(),
+         boost::signals2::trackable(),
          params_(other.params_),
          renderer_(other.renderer_->clone(this))
 {}