use exec except of system() to start external viewer
This commit is contained in:
parent
c9a0172d58
commit
fd0cdcbdcf
@ -1037,12 +1037,6 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
// addition to the path. We store a copy of xdg-open there, to be
|
// addition to the path. We store a copy of xdg-open there, to be
|
||||||
// used as last resort
|
// used as last resort
|
||||||
cmdpath = rclconfig->findFilter(lcmd.front());
|
cmdpath = rclconfig->findFilter(lcmd.front());
|
||||||
// Substitute path for cmd
|
|
||||||
if (!cmdpath.empty()) {
|
|
||||||
lcmd.front() = cmdpath;
|
|
||||||
cmd.erase();
|
|
||||||
stringsToString(lcmd, cmd);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ExecCmd::which(lcmd.front(), cmdpath);
|
ExecCmd::which(lcmd.front(), cmdpath);
|
||||||
}
|
}
|
||||||
@ -1050,7 +1044,9 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
// Specialcase text/html because of the help browser need
|
// Specialcase text/html because of the help browser need
|
||||||
if (cmdpath.empty() && !doc.mimetype.compare("text/html")) {
|
if (cmdpath.empty() && !doc.mimetype.compare("text/html")) {
|
||||||
if (lookForHtmlBrowser(cmdpath)) {
|
if (lookForHtmlBrowser(cmdpath)) {
|
||||||
cmd = cmdpath + " %u";
|
lcmd.clear();
|
||||||
|
lcmd.push_back(cmdpath);
|
||||||
|
lcmd.push_back("%u");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1128,7 +1124,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substitute %xx inside prototype command
|
// Get rid of the command name. lcmd is now argv[1...n]
|
||||||
|
lcmd.pop_front();
|
||||||
|
|
||||||
|
// Substitute %xx inside arguments
|
||||||
string efftime;
|
string efftime;
|
||||||
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
||||||
efftime = doc.dmtime.empty() ? doc.fmtime : doc.dmtime;
|
efftime = doc.dmtime.empty() ? doc.fmtime : doc.dmtime;
|
||||||
@ -1137,22 +1136,28 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
}
|
}
|
||||||
// Try to keep the letters used more or less consistent with the reslist
|
// Try to keep the letters used more or less consistent with the reslist
|
||||||
// paragraph format.
|
// paragraph format.
|
||||||
string ncmd;
|
|
||||||
map<string, string> subs;
|
map<string, string> subs;
|
||||||
subs["D"] = escapeShell(efftime);
|
subs["D"] = efftime;
|
||||||
subs["f"] = escapeShell(fn);
|
subs["f"] = fn;
|
||||||
subs["i"] = escapeShell(doc.ipath);
|
subs["i"] = doc.ipath;
|
||||||
subs["M"] = escapeShell(doc.mimetype);
|
subs["M"] = doc.mimetype;
|
||||||
subs["U"] = escapeShell(url);
|
subs["U"] = url;
|
||||||
subs["u"] = escapeShell(url);
|
subs["u"] = url;
|
||||||
// Let %(xx) access all metadata.
|
// Let %(xx) access all metadata.
|
||||||
for (map<string,string>::const_iterator it = doc.meta.begin();
|
for (map<string,string>::const_iterator it = doc.meta.begin();
|
||||||
it != doc.meta.end(); it++) {
|
it != doc.meta.end(); it++) {
|
||||||
subs[it->first] = escapeShell(it->second);
|
subs[it->first] = it->second;
|
||||||
|
}
|
||||||
|
string ncmd;
|
||||||
|
for (list<string>::iterator it = lcmd.begin();
|
||||||
|
it != lcmd.end(); it++) {
|
||||||
|
pcSubst(*it, ncmd, subs);
|
||||||
|
LOGDEB(("%s->%s\n", it->c_str(), ncmd.c_str()));
|
||||||
|
*it = ncmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also substitute inside the unsplitted command line for displaying
|
||||||
pcSubst(cmd, ncmd, subs);
|
pcSubst(cmd, ncmd, subs);
|
||||||
|
|
||||||
ncmd += " &";
|
ncmd += " &";
|
||||||
QStatusBar *stb = statusBar();
|
QStatusBar *stb = statusBar();
|
||||||
if (stb) {
|
if (stb) {
|
||||||
@ -1166,11 +1171,11 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
|
|
||||||
if (!istempfile)
|
if (!istempfile)
|
||||||
historyEnterDoc(g_dynconf, doc.meta[Rcl::Doc::keyudi]);
|
historyEnterDoc(g_dynconf, doc.meta[Rcl::Doc::keyudi]);
|
||||||
|
|
||||||
// We should actually monitor these processes so that we can
|
// We keep pushing back and never deleting. This can't be good...
|
||||||
// delete the temp files when they exit
|
ExecCmd *ecmd = new ExecCmd;
|
||||||
LOGDEB(("Executing: [%s]\n", ncmd.c_str()));
|
m_viewers.push_back(ecmd);
|
||||||
system(ncmd.c_str());
|
ecmd->startExec(cmdpath, lcmd, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::startManual()
|
void RclMain::startManual()
|
||||||
|
|||||||
@ -31,6 +31,8 @@
|
|||||||
#include "refcntr.h"
|
#include "refcntr.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
|
|
||||||
|
class ExecCmd;
|
||||||
|
|
||||||
#if QT_VERSION < 0x040000
|
#if QT_VERSION < 0x040000
|
||||||
#include "rclmain.h"
|
#include "rclmain.h"
|
||||||
#else
|
#else
|
||||||
@ -130,6 +132,7 @@ private:
|
|||||||
QTimer *periodictimer;
|
QTimer *periodictimer;
|
||||||
|
|
||||||
vector<TempFile> m_tempfiles;
|
vector<TempFile> m_tempfiles;
|
||||||
|
vector<ExecCmd*> m_viewers;
|
||||||
map<QString, int> m_stemLangToId;
|
map<QString, int> m_stemLangToId;
|
||||||
vector<string> m_catgbutvec;
|
vector<string> m_catgbutvec;
|
||||||
int m_idNoStem;
|
int m_idNoStem;
|
||||||
|
|||||||
@ -127,7 +127,7 @@ public:
|
|||||||
~ExecCmdRsrc() {
|
~ExecCmdRsrc() {
|
||||||
if (!m_active || !m_parent)
|
if (!m_active || !m_parent)
|
||||||
return;
|
return;
|
||||||
LOGDEB0(("~ExecCmdRsrc: working\n"));
|
LOGDEB1(("~ExecCmdRsrc: working. mypid: %d\n", (int)getpid()));
|
||||||
int status;
|
int status;
|
||||||
if (m_parent->m_pid > 0) {
|
if (m_parent->m_pid > 0) {
|
||||||
LOGDEB(("ExecCmd: killing cmd\n"));
|
LOGDEB(("ExecCmd: killing cmd\n"));
|
||||||
|
|||||||
@ -199,6 +199,9 @@ class ExecCmd {
|
|||||||
// Child process code
|
// Child process code
|
||||||
void dochild(const string &cmd, const list<string>& args,
|
void dochild(const string &cmd, const list<string>& args,
|
||||||
bool has_input, bool has_output);
|
bool has_input, bool has_output);
|
||||||
|
/* Copyconst and assignment private and forbidden */
|
||||||
|
ExecCmd(const ExecCmd &) {}
|
||||||
|
ExecCmd& operator=(const ExecCmd &) {return *this;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user