GUI: on windows, pass recollindex args through temp file

This commit is contained in:
Jean-Francois Dockes 2020-04-14 17:36:45 +02:00
parent d28cb0230d
commit 71368b3134
2 changed files with 39 additions and 3 deletions

View File

@ -222,10 +222,40 @@ void RclMain::periodic100()
fileExit();
}
// On win32 we have trouble passing filename args on the command line
// (recollindex would need to use wmain and process wchar args. So we
// use a temp file: if the first and only arg to recollindex is not an
// option, it's a file with the command line inside it.
bool RclMain::maybeArgsToFile(vector<string>& args)
{
#ifdef _WIN32
if (!m_idxargstmp || !m_idxargstmp->ok()) {
TempFile temp("");
m_idxargstmp = rememberTempFile(temp);
}
string s;
stringsToString(args, s);
fstream fout(m_idxargstmp->filename(), ios::out|ios::trunc);
fout << s;
fout.close();
return true;
if (args[0] == "recollindex") {
args = {args[0], m_idxargstmp->filename()};
} else {
args = {m_idxargstmp->filename()};
}
return true;
#else
args = args;
return true;
#endif
}
bool RclMain::checkIdxPaths()
{
string badpaths;
vector<string> args {"recollindex", "-c", theconfig->getConfDir(), "-E"};
vector<string> args{"recollindex", "-c", theconfig->getConfDir(), "-E"};
maybeArgsToFile(args);
ExecCmd::backtick(args, badpaths);
if (!badpaths.empty()) {
int rep = QMessageBox::warning(
@ -295,6 +325,7 @@ void RclMain::toggleIndexing()
args.push_back(m_idxreasontmp->filename());
}
m_idxproc = new ExecCmd;
maybeArgsToFile(args);
m_idxproc->startExec("recollindex", args, false, false);
}
break;
@ -400,6 +431,7 @@ void RclMain::rebuildIndex()
args.push_back(m_idxreasontmp->filename());
}
m_idxproc = new ExecCmd;
maybeArgsToFile(args);
m_idxproc->startExec("recollindex", args, false, false);
}
}
@ -526,6 +558,7 @@ void RclMain::specialIndex()
args.push_back(top);
}
m_idxproc = new ExecCmd;
maybeArgsToFile(args);
LOGINFO("specialIndex: exec: " << execToString("recollindex", args) <<endl);
m_idxproc->startExec("recollindex", args, false, false);
}
@ -548,6 +581,7 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
}
args.insert(args.end(), paths.begin(), paths.end());
m_idxproc = new ExecCmd;
maybeArgsToFile(args);
m_idxproc->startExec("recollindex", args, false, false);
// Call periodic100 to update the menu entries states
periodic100();

View File

@ -66,7 +66,7 @@ public:
QString getQueryDescription();
/** This is only called from main() to set an URL to be displayed (using
recoll as a doc extracter for embedded docs */
recoll as a doc extracter for embedded docs */
virtual void setUrlToView(const QString& u) {
m_urltoview = u;
}
@ -130,7 +130,7 @@ public slots:
virtual void startPreview(int docnum, Rcl::Doc doc, int keymods);
virtual void startPreview(Rcl::Doc);
virtual void startNativeViewer(Rcl::Doc, int pagenum = -1,
QString term = QString());
QString term = QString());
virtual void openWith(Rcl::Doc, string);
virtual void saveDocToFile(Rcl::Doc);
virtual void previewNextInTab(Preview *, int sid, int docnum);
@ -208,6 +208,7 @@ private:
ExecCmd *m_idxproc{0}; // Indexing process
bool m_idxkilled{false}; // Killed my process
TempFile *m_idxreasontmp{nullptr};
TempFile *m_idxargstmp{nullptr};
map<QString, QAction*> m_stemLangToId;
vector<string> m_catgbutvec;
int m_catgbutvecidx{0};
@ -250,6 +251,7 @@ private:
virtual bool containerUpToDate(Rcl::Doc& doc);
virtual void setFiltSpec();
virtual bool checkIdxPaths();
bool maybeArgsToFile(std::vector<std::string>& args);
};
#endif // RCLMAIN_W_H