Merge #15208: Qt: remove macOS launch-at-startup when compiled with > macOS 10.11, fix memory missmanagement
da6011826a
Fix macOS launch-at-startup memory issue (Jonas Schnelli)516437a1b7
Qt: remove macOS launch-at-startup option when compiled with > macOS 10.11 (Jonas Schnelli) Pull request description: The launch-at-startup API Bitcoin Core uses on macOS where removed in macOS 10.11 leading to a segmentation-fault due to the weak-linking when not actively compiled against SDK 10.11 (`-mmacosx-version-min=10.11`) This PR removes the launch-at-startup feature on macOS when compiled with macOS min version > 10.11 (the default is always the macOS version you compile on). **The depends built binaries (Gitian) are not affected since we are building with min macOS 10.10.** Users self compiling on macOS > 10.11 can re-enable the feature by compiling with min version <= 10.11 (`CXXFLAGS="-mmacosx-version-min=10.11" CFLAGS="-mmacosx-version-min=10.11" ./configure`) **Isn't there a new API from Apple?** Yes, [there is](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLoginItems.html). It will require to create a helper application which needs to be embedded in the .app folder (needs code signing as well). Developers willing to go down that rabbit hole are welcome. Fixes #15142 Tree-SHA512: fa9cc4e39d5a2d2559919b7e22b7766f5e0269a361719294d4a4a2df2fd9d955e5b23b5907e68023fdeee297f652f844f3c447904bf18f9c1145348ad101c432
This commit is contained in:
commit
94167e2b5b
3 changed files with 23 additions and 11 deletions
|
@ -262,6 +262,12 @@ Graphical User Interface (GUI)
|
||||||
balance shown if the wallet was created using the `createwallet` RPC
|
balance shown if the wallet was created using the `createwallet` RPC
|
||||||
and the `disable_private_keys` parameter was set to true.
|
and the `disable_private_keys` parameter was set to true.
|
||||||
|
|
||||||
|
- The launch-on-startup option is no longer available on macOS if
|
||||||
|
compiled with macosx min version greater than 10.11 (use
|
||||||
|
CXXFLAGS="-mmacosx-version-min=10.11"
|
||||||
|
CFLAGS="-mmacosx-version-min=10.11" for setting the deployment
|
||||||
|
sdk version)
|
||||||
|
|
||||||
Low-level changes
|
Low-level changes
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
|
@ -683,13 +683,11 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 101100
|
||||||
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
|
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
|
||||||
|
|
||||||
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl);
|
LSSharedFileListItemRef findStartupItemInList(CFArrayRef listSnapshot, LSSharedFileListRef list, CFURLRef findUrl)
|
||||||
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
|
|
||||||
{
|
{
|
||||||
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, nullptr);
|
|
||||||
if (listSnapshot == nullptr) {
|
if (listSnapshot == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -714,15 +712,12 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef
|
||||||
if(currentItemURL) {
|
if(currentItemURL) {
|
||||||
if (CFEqual(currentItemURL, findUrl)) {
|
if (CFEqual(currentItemURL, findUrl)) {
|
||||||
// found
|
// found
|
||||||
CFRelease(listSnapshot);
|
|
||||||
CFRelease(currentItemURL);
|
CFRelease(currentItemURL);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
CFRelease(currentItemURL);
|
CFRelease(currentItemURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(listSnapshot);
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,10 +729,12 @@ bool GetStartOnSystemStartup()
|
||||||
}
|
}
|
||||||
|
|
||||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
|
||||||
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
|
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(loginItems, nullptr);
|
||||||
|
bool res = (findStartupItemInList(listSnapshot, loginItems, bitcoinAppUrl) != nullptr);
|
||||||
CFRelease(bitcoinAppUrl);
|
CFRelease(bitcoinAppUrl);
|
||||||
return !!foundItem; // return boolified object
|
CFRelease(loginItems);
|
||||||
|
CFRelease(listSnapshot);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetStartOnSystemStartup(bool fAutoStart)
|
bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
|
@ -748,7 +745,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
|
||||||
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
|
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(loginItems, nullptr);
|
||||||
|
LSSharedFileListItemRef foundItem = findStartupItemInList(listSnapshot, loginItems, bitcoinAppUrl);
|
||||||
|
|
||||||
if(fAutoStart && !foundItem) {
|
if(fAutoStart && !foundItem) {
|
||||||
// add bitcoin app to startup item list
|
// add bitcoin app to startup item list
|
||||||
|
@ -760,6 +758,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(bitcoinAppUrl);
|
CFRelease(bitcoinAppUrl);
|
||||||
|
CFRelease(loginItems);
|
||||||
|
CFRelease(listSnapshot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
|
@ -74,6 +74,12 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
/* remove Window tab on Mac */
|
/* remove Window tab on Mac */
|
||||||
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
|
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow));
|
||||||
|
#if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED > 101100
|
||||||
|
/* hide launch at startup option if compiled against macOS > 10.11 (removed API) */
|
||||||
|
ui->bitcoinAtStartup->setVisible(false);
|
||||||
|
ui->verticalLayout_Main->removeWidget(ui->bitcoinAtStartup);
|
||||||
|
ui->verticalLayout_Main->removeItem(ui->horizontalSpacer_0_Main);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* remove Wallet tab in case of -disablewallet */
|
/* remove Wallet tab in case of -disablewallet */
|
||||||
|
|
Loading…
Add table
Reference in a new issue