]> git.lyx.org Git - lyx.git/commitdiff
* src/insets/insetgraphics.C
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 22 May 2006 09:15:33 +0000 (09:15 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 22 May 2006 09:15:33 +0000 (09:15 +0000)
(InsetGraphics::prepareFile): Rename file in the temp dir if the
extension does not match the format (bug 2235)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13898 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/insetgraphics.C

index 35fa59ed1b8e58b77c6fd7a10bc007d2f619a1ec..9a55b8e38beeef139ae716db999efe1d9996b473 100644 (file)
@@ -677,6 +677,20 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
                << "\tthe orig file is: " << orig_file << endl;
 
        if (from == to) {
+               if (!runparams.nice && getExtension(temp_file) != ext) {
+                       // The LaTeX compiler will not be able to determine
+                       // the file format from the extension, so we must
+                       // change it.
+                       string const new_file = changeExtension(temp_file, ext);
+                       if (lyx::support::rename(temp_file, new_file)) {
+                               temp_file = new_file;
+                               output_file = changeExtension(output_file, ext);
+                       } else
+                               lyxerr[Debug::GRAPHICS]
+                                       << "Could not rename file `"
+                                       << temp_file << "' to `" << new_file
+                                       << "'." << endl;
+               }
                // The extension of temp_file might be != ext!
                runparams.exportdata->addExternalFile(tex_format, source_file,
                                                      output_file);