merge #15208: remove macOS launch-at-startup when compiled with > macOS 10.11

This commit is contained in:
Kittywhiskers Van Gogh 2019-01-18 21:47:01 -10:00
parent ced48380b8
commit def36ab1f4
2 changed files with 21 additions and 11 deletions

View File

@ -909,13 +909,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;
} }
@ -940,15 +938,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;
} }
@ -960,10 +955,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)
@ -974,7 +971,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 Dash Core app to startup item list // add Dash Core app to startup item list
@ -986,6 +984,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

View File

@ -89,6 +89,16 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
connect(ui->connectSocksTor, &QPushButton::toggled, ui->proxyPortTor, &QWidget::setEnabled); connect(ui->connectSocksTor, &QPushButton::toggled, ui->proxyPortTor, &QWidget::setEnabled);
connect(ui->connectSocksTor, &QPushButton::toggled, this, &OptionsDialog::updateProxyValidationState); connect(ui->connectSocksTor, &QPushButton::toggled, this, &OptionsDialog::updateProxyValidationState);
/* Window elements init */
#ifdef Q_OS_MAC
#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
pageButtons = new QButtonGroup(this); pageButtons = new QButtonGroup(this);
pageButtons->addButton(ui->btnMain, pageButtons->buttons().size()); pageButtons->addButton(ui->btnMain, pageButtons->buttons().size());
/* Remove Wallet/CoinJoin tabs in case of -disablewallet */ /* Remove Wallet/CoinJoin tabs in case of -disablewallet */