Skip to content

Commit

Permalink
Merge bitcoin#16044: qt: fix opening bitcoin.conf via Preferences on …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
laanwj committed Jun 3, 2019
2 parents 599206f + 6e6494b commit 6520330
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

#include <objc/objc-runtime.h>
#include <CoreServices/CoreServices.h>
#include <QProcess>
#endif

namespace GUIUtil {
Expand Down Expand Up @@ -399,7 +400,15 @@ bool openBitcoinConf()
configFile.close();

/* Open bitcoin.conf with the associated application */
return QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
bool res = QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
#ifdef Q_OS_MAC
// Workaround for macOS-specific behavior; see #15409.
if (!res) {
res = QProcess::startDetached("/usr/bin/open", QStringList{"-t", boostPathToQString(pathConfig)});
}
#endif

return res;
}

ToolTipToRichTextFilter::ToolTipToRichTextFilter(int _size_threshold, QObject *parent) :
Expand Down

0 comments on commit 6520330

Please sign in to comment.