[texworks] New version 302/303

Jonathan Kew jfkthame at googlemail.com
Thu Jun 4 17:57:44 CEST 2009

On 4 Jun 2009, at 11:26, T T wrote:

> This brings me to this pesky
> defaultbinpaths. In the source of TWApp.cpp (current rev.) I find
> this:
> void TWApp::setDefaultPaths()
> {
>        QDir appDir(applicationDirPath());
>        if (binaryPaths == NULL)
>                binaryPaths = new QStringList;
>        else
>                binaryPaths->clear();
>        if (defaultBinPaths)
>                *binaryPaths = *defaultBinPaths;
>        else { // <-- REMOVE THIS
> #ifndef Q_WS_MAC
>                // on OS X, this will be the path to
> {TW_APP_PACKAGE}/Contents/MacOS/
>                // which doesn't make any sense as a search dir for  
> TeX binaries
>                binaryPaths->append(appDir.absolutePath());
> #endif
>                const char *envPath = getenv("PATH");
>                if (envPath != NULL)
>                        foreach (const QString& s,
> QString(envPath).split(PATH_LIST_SEP))
>                        if (!binaryPaths->contains(s))
>                                binaryPaths->append(s);
> #ifdef Q_WS_WIN
>                *binaryPaths
>                        << "c:/texlive/2009/bin"
>                        << "c:/texlive/2008/bin"
>                        << "c:/texlive/2007/bin"
>                        << "c:/w32tex/bin"
>                        << "c:/Program Files/MiKTeX 2.7/miktex/bin"
>                        << "c:/Program Files (x86)/MiKTeX 2.7/miktex/ 
> bin"
>                ;
> #else
>                foreach (const QString& s,
> QString(DEFAULT_BIN_PATHS).split(':'))
>                        if (!binaryPaths->contains(s))
>                                binaryPaths->append(s);
> #endif
>        } // <-- REMOVE THIS
> The 'else' statement (marked with "// <-- REMOVE THIS", which is my
> suggestion)  is executed *only* if defaultBinPaths is NULL (and that
> happens only if defaultbinpaths is not defined in texworks-setup.ini).
> This means that PATH and compiled-in defaults are never appended to
> binaryPaths. Is this the intended behaviour or simply a bug?

That was intended behavior; defaultbinpaths was supposed to  
*override*, not supplement, the compiled-in defaults. (Remember that  
in all cases, this is just providing defaults, which can still be  
modified in Preferences.) If there is a texworks-setup.ini file  
providing the defaults, then we assume that the user/installer/ 
distributor/whoever has put the right path(s) there, and the compile- 
time settings should be ignored.

As for adding the PATH, I don't think this should be necessary anyway,  
as the current $PATH is supposed to be searched automatically in  
addition to the explicitly-listed binary paths. (See  
TeXDocument::typeset(). It first prepends the TeXworks binpaths to the  
PATH in the environment, and then uses the new PATH to actually look  
for the tools, as well as passing this modified PATH to the tool that  
gets executed.)

Still, maybe it's nice to include the PATH in the (default)binpaths  
lists, so that they're explicitly visible to the user.  So I've moved  
this code outside of the conditional (r.305).

> Also, envPath is split with `QString(envPath).split(PATH_LIST_SEP)',
> while defaultBinPaths is assigned with:
> *defaultBinPaths = portable.value("defaultbinpaths").toStringList();
> Are these two equivalent? What separator is used for splitting in case
> of `toStringList' method? If defaultbinpaths is not split properly,
> maybe it could explain why tex bin dir has to be the first element of
> defaultbinpaths (this still doesn't explain why Alain's settings don't
> work, while very similar ones work for me). Can anyone make some sense
> of it?

I think this is a real bug, and probably the cause of a lot of the  
problems surrounding defaultbinpaths. toStringList() is the correct  
method to use when retrieving a QStringList that has been stored into  
preferences (as QVariant), but it is *not* the right way to handle the  
string value of defaultbinpaths. That should be explicitly split() on  
the PATH_LIST_SEP delimiter.

I've just committed this fix (r.304).

Many thanks,


More information about the texworks mailing list