Skip to content

Commit 4fb82e9

Browse files
committed
Merge #17567: gui: remove macOS start on login code
27d82b6 gui: remove macOS start on login code (fanquake) Pull request description: The macOS startup item code was disabled for builds targeting macOS > `10.11` in #15208. Now that we require macOS `10.12` as a minimum (#17550), we can remove the startup item code entirely. The API we were using, `LSSharedFileListItemCopyResolvedURL`, `LSSharedFileListCopySnapshot` etc, was removed in macOS `10.12` SDK. ACKs for top commit: jonasschnelli: utACK 27d82b6 jonasschnelli: Tested ACK 27d82b6 - successfully compiled on 10.15.1 Tree-SHA512: 7420757b91c7820e6a63280887155394547134a9cebcf3721af0284da23292627f94cd431241e033075b3fd86d79ace3ebf1b25d17763acbf71e07a742395409
2 parents f2ab130 + 27d82b6 commit 4fb82e9

File tree

3 files changed

+3
-87
lines changed

3 files changed

+3
-87
lines changed

doc/release-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ Low-level Changes section below.
9090
GUI changes
9191
-----------
9292

93+
- The "Start Bitcoin Core on system login" option has been removed on macOS.
94+
9395
Wallet
9496
------
9597

src/qt/guiutil.cpp

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@
5454
#include <QUrlQuery>
5555

5656
#if defined(Q_OS_MAC)
57-
#pragma GCC diagnostic push
58-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
5957

60-
#include <CoreServices/CoreServices.h>
6158
#include <QProcess>
6259

6360
void ForceActivation();
@@ -691,87 +688,6 @@ bool SetStartOnSystemStartup(bool fAutoStart)
691688
return true;
692689
}
693690

694-
695-
#elif defined(Q_OS_MAC) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 101100
696-
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
697-
698-
LSSharedFileListItemRef findStartupItemInList(CFArrayRef listSnapshot, LSSharedFileListRef list, CFURLRef findUrl)
699-
{
700-
if (listSnapshot == nullptr) {
701-
return nullptr;
702-
}
703-
704-
// loop through the list of startup items and try to find the bitcoin app
705-
for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) {
706-
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i);
707-
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
708-
CFURLRef currentItemURL = nullptr;
709-
710-
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 10100
711-
if(&LSSharedFileListItemCopyResolvedURL)
712-
currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, nullptr);
713-
#if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 10100
714-
else
715-
LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, nullptr);
716-
#endif
717-
#else
718-
LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, nullptr);
719-
#endif
720-
721-
if(currentItemURL) {
722-
if (CFEqual(currentItemURL, findUrl)) {
723-
// found
724-
CFRelease(currentItemURL);
725-
return item;
726-
}
727-
CFRelease(currentItemURL);
728-
}
729-
}
730-
return nullptr;
731-
}
732-
733-
bool GetStartOnSystemStartup()
734-
{
735-
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
736-
if (bitcoinAppUrl == nullptr) {
737-
return false;
738-
}
739-
740-
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
741-
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(loginItems, nullptr);
742-
bool res = (findStartupItemInList(listSnapshot, loginItems, bitcoinAppUrl) != nullptr);
743-
CFRelease(bitcoinAppUrl);
744-
CFRelease(loginItems);
745-
CFRelease(listSnapshot);
746-
return res;
747-
}
748-
749-
bool SetStartOnSystemStartup(bool fAutoStart)
750-
{
751-
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
752-
if (bitcoinAppUrl == nullptr) {
753-
return false;
754-
}
755-
756-
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
757-
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(loginItems, nullptr);
758-
LSSharedFileListItemRef foundItem = findStartupItemInList(listSnapshot, loginItems, bitcoinAppUrl);
759-
760-
if(fAutoStart && !foundItem) {
761-
// add bitcoin app to startup item list
762-
LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst, nullptr, nullptr, bitcoinAppUrl, nullptr, nullptr);
763-
}
764-
else if(!fAutoStart && foundItem) {
765-
// remove item
766-
LSSharedFileListItemRemove(loginItems, foundItem);
767-
}
768-
769-
CFRelease(bitcoinAppUrl);
770-
CFRelease(loginItems);
771-
CFRelease(listSnapshot);
772-
return true;
773-
}
774-
#pragma GCC diagnostic pop
775691
#else
776692

777693
bool GetStartOnSystemStartup() { return false; }

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
7171
#ifdef Q_OS_MAC
7272
/* remove Window tab on Mac */
7373
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
74-
#if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED > 101100
75-
/* hide launch at startup option if compiled against macOS > 10.11 (removed API) */
74+
/* hide launch at startup option on macOS */
7675
ui->bitcoinAtStartup->setVisible(false);
7776
ui->verticalLayout_Main->removeWidget(ui->bitcoinAtStartup);
7877
ui->verticalLayout_Main->removeItem(ui->horizontalSpacer_0_Main);
79-
#endif
8078
#endif
8179

8280
/* remove Wallet tab in case of -disablewallet */

0 commit comments

Comments
 (0)