View Issue Details

IDProjectCategoryView StatusLast Update
0016924ScribusGeneralpublic2023-05-29 18:56
Reporterale Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.7.0.svn 
Fixed in Version1.7.0.svn 
Summary0016924: render frame with latex does not give any output
Descriptionon linux pdflatex is installed and in the preferences i have:

pdflatex --interaction nonstopmode

the error message in the terminal is:

QObject::connect: No such signal QProcess::error(QProcess::ProcessError) in scribus/scribus/pageitem_latexframe.cpp:55
TagsNo tags attached.
PatchNo

Activities

ale

2023-04-05 17:26

manager   ~0050079

p.s. i've tested pdflatex with this sample document in the terminal and it did work...

\documentclass{article}
\begin{document}
  Hello World!
\end{document}

ale

2023-04-05 17:43

manager   ~0050080

using the modern syntax for connects helps finding the error:

connect(latex, &QProcess::errorOccurred, this, &PageItem_LatexFrame::latexError);


while

connect(latex, &QProcess::error, this, &PageItem_LatexFrame::latexError);

does not compile, connecting errorOccurred gives me an error message and tells me to check the (i guess supposed empty) path.

ale

2023-04-05 17:50

manager   ~0050081

using the full path to pdflatex in the settings does not help either.

ale

2023-04-05 17:52

manager   ~0050082

also, in latexError() there is a "firstWarning" condition that makes that dialog only show for the first a latex frame is inserted (updated...) since scribus started.

it should probably pop up each time a new frame is created or at least after having modified the renderer settings.

ale

2023-04-05 18:27

manager   ~0050083

so, while scribus fails to launch the command

"pdflatex --interaction nonstopmode \"/tmp/scribus_temp_render_hVVUlp\"" .



doing "cat /tmp/scribus_temp_render_hVVUlp" while the error dialog is still open, shows


        \documentclass[11pt]{extarticle}
        \usepackage[utf8]{inputenc}
        \usepackage[paperwidth=134.4 pt,
                    paperheight=124.355 pt,
                    left=0cm,top=0cm,right=0cm,bottom=0cm,nohead,nofoot]{geometry}
        \title{Scribus-Latex-File}

        \usepackage{amsmath}
        \author{Scribus}
        \pagestyle{empty}
        \setlength{\textwidth}{134.4 pt}
        \begin{document}
    \section*{Manual}
Your \LaTeX-frames setup is working when you can read this text!\\
Placing formulas is very easy:\\
Right click $\Rightarrow$ Edit Source\\
And replace this text with your own. Here is an example:
\begin{verbatim}
    \[J = \int r^2 \mathrm{d}m\]
\end{verbatim}
becomes
\[J = \int r^2 \mathrm{d}m\]
        \end{document}

the file is there.

running the exact same command as above (qDebug() << fullCommand) in the terminal, while the error dialog is still open, does work.

here is my last try:

    full_command = config->executable();
    QStringList arguments {QDir::toNativeSeparators(tempFileBase)};
    latex->start(full_command, arguments);

also fails.

there is something "interesting", though: when running from the terminal, the pdf file gets (obviously) created in the current directory and not in /tmp...
still

    QStringList arguments {"-output-directory="+QDir::tempPath(), QDir::toNativeSeparators(tempFileBase)};

does not to seem to help either.

something is wrong somewhere... but i don't seem to be able to find out what...

jghali

2023-04-05 20:01

administrator   ~0050085

I have also "pdflatex --interaction nonstopmode" but no issue here...

jghali

2023-04-05 20:12

administrator   ~0050086

At least we won't take any risk by replacing the deprecated error() signal by errorOccurred(). I just checked: errorOccurred() was already available in Qt 5.14.

ale

2023-04-05 20:17

manager   ~0050087

Last edited: 2023-04-05 20:18

replacing

    latex->start(full_command);

by

    latex->start("pdflatex", QStringList() << "--interaction nonstopmode" << tempFileBase);

does work...

yeah.

i can replicate this in a dummy application that only triggers the QProcess so i fear that with Qt6 it's not possible anymore to put all the command line arguments in the command itself.

Luna Nightshade

2023-04-05 20:26

reporter   ~0050088

I have been messing around with the code, and after removing the parameter "--interaction nonstopmode" from the arguments in the preferences, I got it to work.
I fear you need to fully separate out the arguments from the command.

jghali

2023-04-05 20:34

administrator   ~0050089

>> i can replicate this in a dummy application that only triggers the QProcess so i fear that with Qt6 it's not possible anymore to put all the command line arguments in the command itself.

Well, on Windows i currently do not have this problem with Qt 6.2.4. It might also be a Qt regression. What Qt version are you currently using? I expect to upgrade to Qt 6.5.0 this week-end so I'll test what happens with Qt 6.5 soon.

ale

2023-04-05 20:47

manager   ~0050091

it should be qt 6.4.2.

Luna Nightshade

2023-04-05 21:06

reporter   ~0050092

I have the same problem on linux. In about Qt is shown as 6.2.4.
Might be a difference in how linux handles these commands.

P.S.:
Can't the following code be removed (just before latex->start(...))
    full_command.replace("%dpi", QString::number(realDpi()));
    if (full_command.contains("%file"))
        full_command.replace("%file", QString("\"%1\"").arg(QDir::toNativeSeparators(tempFileBase)));
    else
        full_command = full_command + QString(" \"%1\"").arg(QDir::toNativeSeparators(tempFileBase));

    full_command.replace("%dir", QString("\"%1\"").arg(QDir::toNativeSeparators(QDir::tempPath())));
    latex->setWorkingDirectory(QDir::tempPath());

    double lDpi = realDpi()/72.0;
    full_command.replace("$scribus_height_px$", QString::number(qRound(m_height*lDpi)));
    full_command.replace("$scribus_width_px$", QString::number(qRound(m_width*lDpi)));
    QMapIterator<QString, QString> i(editorProperties);
    while (i.hasNext())
    {
        i.next();
        full_command.replace("$scribus_"+i.key()+"$", i.value());
    }

All the variables are not part of the command-string ...

jghali

2023-04-05 21:07

administrator   ~0050093

Try this patch meanwhile.
16924_render_frame_not_working.patch (2,266 bytes)   
Index: scribus/pageitem_latexframe.cpp
===================================================================
--- scribus/pageitem_latexframe.cpp	(revision 25406)
+++ scribus/pageitem_latexframe.cpp	(working copy)
@@ -282,23 +282,32 @@
 	}
 	firstWarningLatexMissing = true;
 
-	full_command.replace("%dpi", QString::number(realDpi()));
-	if (full_command.contains("%file"))
-		full_command.replace("%file", QString("\"%1\"").arg(QDir::toNativeSeparators(tempFileBase)));
-	else
-		full_command = full_command + QString(" \"%1\"").arg(QDir::toNativeSeparators(tempFileBase));
+	QStringList args = full_command.split(' ', Qt::SkipEmptyParts);
+	
+	QString program = args.at(0);
+	args.removeFirst();
+	if (!full_command.contains("%file"))
+		args.append(QDir::toNativeSeparators(tempFileBase));
 
-	full_command.replace("%dir", QString("\"%1\"").arg(QDir::toNativeSeparators(QDir::tempPath())));
-	latex->setWorkingDirectory(QDir::tempPath());
+	double lDpi = realDpi() / 72.0;
+	for (qsizetype i = 0; i < args.size(); ++i)
+	{
+		QString arg = args.at(i);
+		arg.replace("%dpi", QString::number(realDpi()));
+		if (arg.contains("%file"))
+			arg.replace("%file", QDir::toNativeSeparators(tempFileBase));
+		arg.replace("%dir", QDir::toNativeSeparators(QDir::tempPath()));
 
-	double lDpi = realDpi()/72.0;
-	full_command.replace("$scribus_height_px$", QString::number(qRound(m_height*lDpi)));
-	full_command.replace("$scribus_width_px$",  QString::number(qRound(m_width*lDpi)));
-	QMapIterator<QString, QString> i(editorProperties);
-	while (i.hasNext())
-	{
-		i.next();
-		full_command.replace("$scribus_"+i.key()+"$", i.value());
+		arg.replace("$scribus_height_px$", QString::number(qRound(m_height * lDpi)));
+		arg.replace("$scribus_width_px$", QString::number(qRound(m_width * lDpi)));
+		QMapIterator<QString, QString> it(editorProperties);
+		while (it.hasNext())
+		{
+			it.next();
+			arg.replace("$scribus_" + it.key() + "$", it.value());
+		}
+
+		args[i] = arg;
 	}
 	
 	imageFile = tempFileBase + config->imageExtension();
@@ -306,7 +315,8 @@
 	writeFileContents(&tempfile);
 	tempfile.close();
 	
-	latex->start(full_command);
+	latex->setWorkingDirectory(QDir::tempPath());
+	latex->start(program, args);
 	emit stateChanged(QProcess::Starting);
 }
 

Luna Nightshade

2023-04-05 21:20

reporter   ~0050094

Seems to work flawlessly.

ale

2023-04-05 21:26

manager   ~0050095

i did not try it, but the above code will probably fail if somebody uses the full path to pdflatex and that path happens to contain spaces (which is very unlikely on a linux default install but could easily happen on windows or ios where people need to "manually" install latex).

Luna Nightshade

2023-04-05 21:43

reporter   ~0050096

In this case, the config should be split into two parts. One for the path of the executable (or the name) and one for the args, as you can't reliably split them in code.

It does work as a hotfix (but so does removing the arg "--interaction nonstopmode" for pdflatex; sadly it seems that it's not possible for every external program to remove the arguments.)

jghali

2023-04-06 19:22

administrator   ~0050098

>> i did not try it, but the above code will probably fail if somebody uses the full path to pdflatex

It should not because QProcess automatically quotes arguments when necessary. The full path to my latex installation contains spaces as well as the path of my temporary directory.

Luna Nightshade

2023-04-07 06:42

reporter   ~0050099

Did you enter the full path to pdflatex first, or is pdflatex found by the PATH variable?

Because in theory, entering a full path, should result in the following:

program: "C:\Program"
arguments: "Files\...\pdflatex", "--interaction", "nonstopmode" and "$TMPPATH" the arguments will work well. The problem is the full path to the program, if you need to give it. May be an edge case though.

ale

2023-04-07 08:17

manager   ~0050100

if i get it correctly, you are splitting by spaces the full_command from the settings

QStringList args = full_command.split(' ', Qt::SkipEmptyParts);

take the first item as the command

QString program = args.at(0);
args.removeFirst();

and use the rest as the args.

if there is a space in the path, you will get the first part of the path as the program and the rest of the path with the command in the first argument...

if it this is what happens, i would prefer utnik suggestion and have two fields in the settings: one for the program and one for the arguments.
(for the old values currently in the settings, everything would still be in the full_program... or we could detect if the command is still at its default and if it's the case use the new default values)

jghali

2023-04-09 23:24

administrator   ~0050106

Last edited: 2023-04-09 23:25

Ah! I thought you were talking about QProcess ability to run program containing spaces in its path. I was conscious of the issue you are talking about and that's why I did not commit that initial patch. I just committed another one where I use new QProcess::splitCommand() introduced in Qt 5.15 to parse command line string. This function supports parsing arguments containing spaces when these arguments are enclosed in quotes.

I also found another issue which could trigger a render frame configuration error message. The issue was caused by a similar split by using space as delimiter. I fixed this separate issue in 1.5.9.svn and trunk. In the case of 1.5.9.svn I copied QProcess::splitCommand() code in our code base as Qt 5.14 is still the minimum supported Qt version in this branch.

ale

2023-04-11 06:42

manager   ~0050109

ok, thanks for fixing this!

Issue History

Date Modified Username Field Change
2023-04-05 15:35 ale New Issue
2023-04-05 17:26 ale Note Added: 0050079
2023-04-05 17:43 ale Note Added: 0050080
2023-04-05 17:43 ale File Added: latex-frame-error-check-path.png
2023-04-05 17:50 ale Note Added: 0050081
2023-04-05 17:52 ale Note Added: 0050082
2023-04-05 18:27 ale Note Added: 0050083
2023-04-05 20:01 jghali Note Added: 0050085
2023-04-05 20:12 jghali Note Added: 0050086
2023-04-05 20:17 ale Note Added: 0050087
2023-04-05 20:18 ale Note Edited: 0050087
2023-04-05 20:26 Luna Nightshade Note Added: 0050088
2023-04-05 20:34 jghali Note Added: 0050089
2023-04-05 20:47 ale Note Added: 0050091
2023-04-05 21:06 Luna Nightshade Note Added: 0050092
2023-04-05 21:07 jghali Note Added: 0050093
2023-04-05 21:07 jghali File Added: 16924_render_frame_not_working.patch
2023-04-05 21:20 Luna Nightshade Note Added: 0050094
2023-04-05 21:26 ale Note Added: 0050095
2023-04-05 21:43 Luna Nightshade Note Added: 0050096
2023-04-06 19:22 jghali Note Added: 0050098
2023-04-07 06:42 Luna Nightshade Note Added: 0050099
2023-04-07 08:17 ale Note Added: 0050100
2023-04-09 23:24 jghali Note Added: 0050106
2023-04-09 23:25 jghali Note Edited: 0050106
2023-04-09 23:25 jghali Note Edited: 0050106
2023-04-09 23:25 jghali Assigned To => jghali
2023-04-09 23:25 jghali Status new => resolved
2023-04-09 23:25 jghali Resolution open => fixed
2023-04-09 23:25 jghali Fixed in Version => 1.7.0.svn
2023-04-11 06:42 ale Note Added: 0050109
2023-05-29 18:56 cbradney Status resolved => closed