]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsConverter.cpp
GuiTabular.cpp: don't hardcode decimal align combobox item
[lyx.git] / src / graphics / GraphicsConverter.cpp
index 917681256e64f5f8e545ee3befe7ac9d8905f1de..ccfb57ce4b4a02f9dfa3a1507713de677856987c 100644 (file)
@@ -250,7 +250,8 @@ static void build_conversion_command(string const & command, ostream & script)
                  "    sys.exit(1)\n\n";
 
        // Delete the infile
-       script << "unlinkNoThrow(infile)\n\n";
+       script << "if infile != outfile:\n"
+                 "  unlinkNoThrow(infile)\n\n";
 }
 
 
@@ -348,7 +349,18 @@ static void build_script(string const & from_file,
                // Build the conversion command
                string const infile      = outfile;
                string const infile_base = changeExtension(infile, string());
-               outfile = addExtension(to_base, conv.To->extension());
+               outfile = conv.result_file.empty()
+                       ? addExtension(to_base, conv.To->extension())
+                       : addName(subst(conv.result_dir,
+                                       token_base, infile_base),
+                                 subst(conv.result_file,
+                                       token_base, onlyFileName(infile_base)));
+
+               // If two formats share the same extension we may get identical names
+               if (outfile == infile && conv.result_file.empty()) {
+                       string const new_base = FileName::tempName(tmp).toFilesystemEncoding();
+                       outfile = addExtension(new_base, conv.To->extension());
+               }
 
                // Store these names in the python script
                script << "infile = "