On Tue, Jun 19, 2007 at 04:22:59PM -0300, Fernando Roig wrote:
> Hi developers:
> 
> I am running LyX 1.5.0rc1 on Windows XP SP2. When I include an eps  
> graph, LyX is not able to show it but displays the message "Error  
> converting to loadable format"
> 
> I run lyxc.exe -dbg graphics and got the output below when including  
> the graph.
> 
> Does anybody knows what is going on?

I can reproduce this bug. It occurs when the temp dir contains nonascii
characters. The attached patch fixes it. José, OK to commit?

-- 
Enrico
Index: src/graphics/GraphicsConverter.cpp
===================================================================
--- src/graphics/GraphicsConverter.cpp  (revision 18837)
+++ src/graphics/GraphicsConverter.cpp  (working copy)
@@ -226,8 +226,8 @@ static string const move_file(string con
                return string();
 
        ostringstream command;
-       command << "fromfile = " << from_file << "\n"
-               << "tofile = "   << to_file << "\n\n"
+       command << "fromfile = utf8ToDefaultEncoding(" << from_file << ")\n"
+               << "tofile = utf8ToDefaultEncoding("   << to_file << ")\n\n"
                << "try:\n"
                << "  os.rename(fromfile, tofile)\n"
                << "except:\n"
@@ -323,7 +323,8 @@ static void build_script(FileName const 
        script << "infile = utf8ToDefaultEncoding("
                        << quoteName(from_file.absFilename(), quote_python)
                        << ")\n"
-                 "outfile = " << quoteName(outfile, quote_python) << "\n"
+                 "outfile = utf8ToDefaultEncoding("
+                       << quoteName(outfile, quote_python) << ")\n"
                  "shutil.copy(infile, outfile)\n";
 
        // Some converters (e.g. lilypond) can only output files to the
@@ -331,15 +332,16 @@ static void build_script(FileName const 
        // This has the added benefit that all other files that may be
        // generated by the converter are deleted when LyX closes and do not
        // clutter the real working directory.
-       script << "os.chdir(" << quoteName(onlyPath(outfile)) << ")\n";
+       script << "os.chdir(utf8ToDefaultEncoding("
+              << quoteName(onlyPath(outfile)) << "))\n";
 
        if (edgepath.empty()) {
                // Either from_format is unknown or we don't have a
                // converter path from from_format to to_format, so we use
                // the default converter.
                script << "infile = outfile\n"
-                      << "outfile = " << quoteName(to_file, quote_python)
-                      << '\n';
+                      << "outfile = utf8ToDefaultEncoding("
+                      << quoteName(to_file, quote_python) << ")\n";
 
                ostringstream os;
                os << support::os::python() << ' '
@@ -379,9 +381,12 @@ static void build_script(FileName const 
                outfile = addExtension(to_base.absFilename(), 
conv.To->extension());
 
                // Store these names in the python script
-               script << "infile = "      << quoteName(infile, quote_python) 
<< "\n"
-                         "infile_base = " << quoteName(infile_base, 
quote_python) << "\n"
-                         "outfile = "     << quoteName(outfile, quote_python) 
<< '\n';
+               script << "infile = utf8ToDefaultEncoding("
+                               << quoteName(infile, quote_python) << ")\n"
+                         "infile_base = utf8ToDefaultEncoding("
+                               << quoteName(infile_base, quote_python) << ")\n"
+                         "outfile = utf8ToDefaultEncoding("
+                               << quoteName(outfile, quote_python) << ")\n";
 
                // See comment about extra " quotes above (although that
                // applies only for the first loop run here).

Reply via email to