File tree Expand file tree Collapse file tree 5 files changed +21
-6
lines changed Expand file tree Collapse file tree 5 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -1038,7 +1038,7 @@ void FilesDock::addOpenWithMenu(QMenu *menu)
10381038 auto action = subMenu->addAction (QFileInfo (program).baseName (), this , [=]() {
10391039 const auto filePath = firstSelectedFilePath ();
10401040 LOG_DEBUG () << program << filePath;
1041- QProcess ::startDetached (program, {QDir::toNativeSeparators (filePath)});
1041+ Util ::startDetached (program, {QDir::toNativeSeparators (filePath)});
10421042 });
10431043 action->setObjectName (program);
10441044 }
@@ -1280,7 +1280,7 @@ void FilesDock::onOpenOtherAdd()
12801280
12811281 const auto program = Util::getExecutable (&MAIN);
12821282 if (!program.isEmpty ()) {
1283- if (QProcess ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
1283+ if (Util ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
12841284 Settings.setFilesOpenOther (firstSelectedMediaType (), program);
12851285 }
12861286 }
Original file line number Diff line number Diff line change 4242#include < QMediaDevices>
4343#include < QMessageBox>
4444#include < QProcess>
45+ #include < QProcessEnvironment>
4546#include < QRegularExpression>
4647#include < QStandardPaths>
4748#include < QStorageInfo>
@@ -1164,3 +1165,16 @@ bool Util::isChromiumAvailable()
11641165 QFileInfo fileInfo (Settings.chromiumPath ());
11651166 return fileInfo.exists () && fileInfo.isExecutable ();
11661167}
1168+
1169+ bool Util::startDetached (const QString &program, const QStringList &arguments)
1170+ {
1171+ QProcess process;
1172+
1173+ #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
1174+ auto env = QProcessEnvironment::systemEnvironment ();
1175+ env.remove (" LD_LIBRARY_PATH" );
1176+ process.setProcessEnvironment (env);
1177+ #endif
1178+
1179+ return process.startDetached (program, arguments);
1180+ }
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ class Util
105105 QObject *receiver,
106106 std::function<void (bool )> callback);
107107 static bool isChromiumAvailable ();
108+ static bool startDetached (const QString &program, const QStringList &arguments);
108109};
109110
110111#endif // UTIL_H
Original file line number Diff line number Diff line change @@ -1630,7 +1630,7 @@ void AvformatProducerWidget::on_openWithButton_clicked()
16301630 for (const auto &program : programs) {
16311631 auto action = menu.addAction (QFileInfo (program).baseName (), this , [=]() {
16321632 LOG_DEBUG () << program << filePath;
1633- if (QProcess ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
1633+ if (Util ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
16341634 m_watcher.reset (new QFileSystemWatcher ({filePath}));
16351635 connect (m_watcher.get (),
16361636 &QFileSystemWatcher::fileChanged,
@@ -1664,7 +1664,7 @@ void AvformatProducerWidget::onOpenOtherAdd()
16641664 const auto program = Util::getExecutable (&MAIN);
16651665 if (!program.isEmpty ()) {
16661666 LOG_DEBUG () << program << filePath;
1667- if (QProcess ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
1667+ if (Util ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
16681668 Settings.setFilesOpenOther (mediaType (), program);
16691669 m_watcher.reset (new QFileSystemWatcher ({filePath}));
16701670 connect (m_watcher.get (),
Original file line number Diff line number Diff line change @@ -530,7 +530,7 @@ void ImageProducerWidget::on_openWithButton_clicked()
530530 for (const auto &program : programs) {
531531 auto action = menu.addAction (QFileInfo (program).baseName (), this , [=]() {
532532 LOG_DEBUG () << program << filePath;
533- if (QProcess ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
533+ if (Util ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
534534 m_watcher.reset (new QFileSystemWatcher ({filePath}));
535535 connect (m_watcher.get (),
536536 &QFileSystemWatcher::fileChanged,
@@ -564,7 +564,7 @@ void ImageProducerWidget::onOpenOtherAdd()
564564 const auto program = Util::getExecutable (&MAIN);
565565 if (!program.isEmpty ()) {
566566 LOG_DEBUG () << program << filePath;
567- if (QProcess ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
567+ if (Util ::startDetached (program, {QDir::toNativeSeparators (filePath)})) {
568568 Settings.setFilesOpenOther (kImageMediaType , program);
569569 m_watcher.reset (new QFileSystemWatcher ({filePath}));
570570 connect (m_watcher.get (),
You can’t perform that action at this time.
0 commit comments