forked from flathub/org.texstudio.TeXstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0001-Add-Flatpak-shim-use-TeX-Live-Flatpak-extension-if-a.patch
136 lines (128 loc) · 5.55 KB
/
0001-Add-Flatpak-shim-use-TeX-Live-Flatpak-extension-if-a.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
From a4059ea3a3a4c979d458d5a7323169589ba3cc73 Mon Sep 17 00:00:00 2001
From: Alexander Wilms <[email protected]>
Date: Tue, 28 Sep 2021 20:33:21 +0200
Subject: [PATCH] Add Flatpak shim, use TeX Live Flatpak extension if available
---
src/execprogram.cpp | 19 ++++++++++++++-----
src/execprogram.h | 5 +++--
src/grammarcheck.cpp | 2 +-
src/texstudio.cpp | 3 ++-
4 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/execprogram.cpp b/src/execprogram.cpp
index f5ca91be..6658f439 100644
--- a/src/execprogram.cpp
+++ b/src/execprogram.cpp
@@ -10,9 +10,10 @@ ExecProgram::ExecProgram(void) :
{
}
-ExecProgram::ExecProgram(const QString &shellCommandLine, const QString &additionalSearchPaths, const QString &workingDirectory) :
+ExecProgram::ExecProgram(const QString &shellCommandLine, const QString &additionalSearchPaths, const QString &workingDirectory, const bool &isBuildCommand) :
m_additionalSearchPaths(additionalSearchPaths),
m_workingDirectory(workingDirectory),
+ m_isBuildCommand(isBuildCommand),
#ifdef Q_OS_WIN
m_winProcModifier(nullptr),
#endif
@@ -22,11 +23,12 @@ ExecProgram::ExecProgram(const QString &shellCommandLine, const QString &additio
setProgramAndArguments(shellCommandLine);
}
-ExecProgram::ExecProgram(const QString &progName, const QStringList &arguments, const QString &additionalSearchPaths, const QString &workingDirectory) :
+ExecProgram::ExecProgram(const QString &progName, const QStringList &arguments, const QString &additionalSearchPaths, const QString &workingDirectory, const bool &isBuildCommand) :
m_program(progName),
m_arguments(arguments),
m_additionalSearchPaths(additionalSearchPaths),
m_workingDirectory(workingDirectory),
+ m_isBuildCommand(isBuildCommand),
#ifdef Q_OS_WIN
m_winProcModifier(nullptr),
#endif
@@ -50,6 +52,13 @@ ExecProgram::ExecProgram(const QString &progName, const QStringList &arguments,
*/
void ExecProgram::setProgramAndArguments(const QString &shellCommandLine)
{
+ QString shellCommandLineShim;
+ if(m_isBuildCommand && QDir("/app/texlive/bin").exists())
+ {
+ shellCommandLineShim = shellCommandLine;
+ } else {
+ shellCommandLineShim = "flatpak-spawn --host "+shellCommandLine;
+ }
static const QRegularExpression rxSpaceSep("\\s+");
Q_ASSERT(rxSpaceSep.isValid());
static const QRegularExpression rxArgPiece(
@@ -62,7 +71,7 @@ void ExecProgram::setProgramAndArguments(const QString &shellCommandLine)
);
Q_ASSERT(rxArgPiece.isValid());
- int shellLineLen = shellCommandLine.length();
+ int shellLineLen = shellCommandLineShim.length();
int shellLineOffset = 0;
QStringList arguments;
QString argText;
@@ -72,7 +81,7 @@ void ExecProgram::setProgramAndArguments(const QString &shellCommandLine)
break;
}
QRegularExpressionMatch matchSpaceSep = rxSpaceSep.match(
- shellCommandLine,
+ shellCommandLineShim,
shellLineOffset,
QRegularExpression::NormalMatch,
QRegularExpression::AnchoredMatchOption
@@ -88,7 +97,7 @@ void ExecProgram::setProgramAndArguments(const QString &shellCommandLine)
}
}
QRegularExpressionMatch matchArgPiece = rxArgPiece.match(
- shellCommandLine,
+ shellCommandLineShim,
shellLineOffset,
QRegularExpression::NormalMatch,
QRegularExpression::AnchoredMatchOption
diff --git a/src/execprogram.h b/src/execprogram.h
index e977e273..9445833d 100644
--- a/src/execprogram.h
+++ b/src/execprogram.h
@@ -7,8 +7,8 @@ class ExecProgram
{
public:
ExecProgram(void);
- ExecProgram(const QString &shellCommandLine, const QString &additionalSearchPaths, const QString &workingDirectory = QString());
- ExecProgram(const QString &progName, const QStringList &arguments, const QString &additionalSearchPaths = QString(), const QString &workingDirectory = QString());
+ ExecProgram(const QString &shellCommandLine, const QString &additionalSearchPaths, const QString &workingDirectory = QString(), const bool &isBuildCommand = true);
+ ExecProgram(const QString &progName, const QStringList &arguments, const QString &additionalSearchPaths = QString(), const QString &workingDirectory = QString(), const bool &isBuildCommand = true);
bool execAndWait(void);
void execAndNoWait(QProcess &proc) const;
@@ -19,6 +19,7 @@ public:
QStringList m_arguments;
QString m_additionalSearchPaths;
QString m_workingDirectory;
+ bool m_isBuildCommand;
#ifdef Q_OS_WIN
QProcess::CreateProcessArgumentModifier m_winProcModifier;
#endif
diff --git a/src/grammarcheck.cpp b/src/grammarcheck.cpp
index d024be9b..4a338b4b 100644
--- a/src/grammarcheck.cpp
+++ b/src/grammarcheck.cpp
@@ -648,7 +648,7 @@ void GrammarCheckLanguageToolJSON::tryToStart()
connect(javaProcess, SIGNAL(finished(int,QProcess::ExitStatus)), javaProcess, SLOT(deleteLater()));
connect(this, SIGNAL(destroyed()), javaProcess, SLOT(deleteLater()));
- javaProcess->start(javaPath,QStringList()<< "-cp" << ltPath << ltArguments.split(" ")); // check sdm
+ javaProcess->start("flatpak-spawn --host " + javaPath,QStringList()<< "-cp" << ltPath << ltArguments.split(" ")); // check sdm
javaProcess->waitForStarted(500);
javaProcess->waitForReadyRead(500);
errorText=javaProcess->readAllStandardError();
diff --git a/src/texstudio.cpp b/src/texstudio.cpp
index ada2e700..b47b736a 100644
--- a/src/texstudio.cpp
+++ b/src/texstudio.cpp
@@ -6024,7 +6024,8 @@ void Texstudio::openExternalTerminal(void)
ExecProgram execProgram(
commandLine,
"",
- QFileInfo(fileCurrent).absolutePath()
+ QFileInfo(fileCurrent).absolutePath(),
+ false
);
#ifdef Q_OS_WIN
execProgram.m_winProcModifier = [] (QProcess::CreateProcessArguments *args) {
--
2.33.0