Skip to content

Commit 6520330

Browse files
committed
Merge bitcoin#16044: qt: fix opening bitcoin.conf via Preferences on macOS
6e6494b qt: fix opening bitcoin.conf via Preferences on macOS; see bitcoin#15409 (shannon1916) Pull request description: Fix bitcoin#15409. The QT wallet fail to open the configuration file on Mac, when these is no default application for `*.conf` files. Here is a feasible way to solve this bug. When `QDesktopServices::openUrl` fails to open `file:///path/bitcoin.conf` with its default application, use `QProcess::startDetached` to run `open -t /path/bitcoin.conf` command instead, so as to open the configuration file with system's default text editor. ACKs for commit 6e6494: hebasto: re-ACK 6e6494b fanquake: tACK bitcoin@6e6494b on macOS 10.14.x Tree-SHA512: 60e898f4cb77cfd7b8adbc8d33fbebf46bac2a801bdcf40cae15e24b78ad56b1f32358b1879b670623d9f8651dea93961d34269358cea18f4e15b089a8ffcfbf
2 parents 599206f + 6e6494b commit 6520330

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/qt/guiutil.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
#include <objc/objc-runtime.h>
6262
#include <CoreServices/CoreServices.h>
63+
#include <QProcess>
6364
#endif
6465

6566
namespace GUIUtil {
@@ -399,7 +400,15 @@ bool openBitcoinConf()
399400
configFile.close();
400401

401402
/* Open bitcoin.conf with the associated application */
402-
return QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
403+
bool res = QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
404+
#ifdef Q_OS_MAC
405+
// Workaround for macOS-specific behavior; see #15409.
406+
if (!res) {
407+
res = QProcess::startDetached("/usr/bin/open", QStringList{"-t", boostPathToQString(pathConfig)});
408+
}
409+
#endif
410+
411+
return res;
403412
}
404413

405414
ToolTipToRichTextFilter::ToolTipToRichTextFilter(int _size_threshold, QObject *parent) :

0 commit comments

Comments
 (0)