Browse Source

Replace less-efficient QProcess::setEnvironment

Also small refactor
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
361afb401b
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 13
      src/base/search/searchpluginmanager.cpp

13
src/base/search/searchpluginmanager.cpp

@ -433,15 +433,13 @@ void SearchPluginManager::updateNova()
void SearchPluginManager::update() void SearchPluginManager::update()
{ {
QProcess nova; QProcess nova;
nova.setEnvironment(QProcess::systemEnvironment()); nova.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
QStringList params;
params << Utils::Fs::toNativePath(engineLocation() + "/nova2.py"); const QStringList params {Utils::Fs::toNativePath(engineLocation() + "/nova2.py"), "--capabilities"};
params << "--capabilities";
nova.start(Utils::ForeignApps::pythonInfo().executableName, params, QIODevice::ReadOnly); nova.start(Utils::ForeignApps::pythonInfo().executableName, params, QIODevice::ReadOnly);
nova.waitForStarted();
nova.waitForFinished(); nova.waitForFinished();
QString capabilities = QString(nova.readAll()); QString capabilities = nova.readAll();
QDomDocument xmlDoc; QDomDocument xmlDoc;
if (!xmlDoc.setContent(capabilities)) { if (!xmlDoc.setContent(capabilities)) {
qWarning() << "Could not parse Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data(); qWarning() << "Could not parse Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data();
@ -466,7 +464,8 @@ void SearchPluginManager::update()
plugin->fullName = engineElem.elementsByTagName("name").at(0).toElement().text(); plugin->fullName = engineElem.elementsByTagName("name").at(0).toElement().text();
plugin->url = engineElem.elementsByTagName("url").at(0).toElement().text(); plugin->url = engineElem.elementsByTagName("url").at(0).toElement().text();
foreach (QString cat, engineElem.elementsByTagName("categories").at(0).toElement().text().split(" ")) { const auto categories = engineElem.elementsByTagName("categories").at(0).toElement().text().split(' ');
for (QString cat : categories) {
cat = cat.trimmed(); cat = cat.trimmed();
if (!cat.isEmpty()) if (!cat.isEmpty())
plugin->supportedCategories << cat; plugin->supportedCategories << cat;

Loading…
Cancel
Save