@@ -686,10 +686,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
686
686
#elif defined(Q_OS_MAC) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 101100
687
687
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
688
688
689
- LSSharedFileListItemRef findStartupItemInList (LSSharedFileListRef list, CFURLRef findUrl);
690
- LSSharedFileListItemRef findStartupItemInList (LSSharedFileListRef list, CFURLRef findUrl)
689
+ LSSharedFileListItemRef findStartupItemInList (CFArrayRef listSnapshot, LSSharedFileListRef list, CFURLRef findUrl)
691
690
{
692
- CFArrayRef listSnapshot = LSSharedFileListCopySnapshot (list, nullptr );
693
691
if (listSnapshot == nullptr ) {
694
692
return nullptr ;
695
693
}
@@ -714,15 +712,12 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef
714
712
if (currentItemURL) {
715
713
if (CFEqual (currentItemURL, findUrl)) {
716
714
// found
717
- CFRelease (listSnapshot);
718
715
CFRelease (currentItemURL);
719
716
return item;
720
717
}
721
718
CFRelease (currentItemURL);
722
719
}
723
720
}
724
-
725
- CFRelease (listSnapshot);
726
721
return nullptr ;
727
722
}
728
723
@@ -734,10 +729,12 @@ bool GetStartOnSystemStartup()
734
729
}
735
730
736
731
LSSharedFileListRef loginItems = LSSharedFileListCreate (nullptr , kLSSharedFileListSessionLoginItems , nullptr );
737
- LSSharedFileListItemRef foundItem = findStartupItemInList (loginItems, bitcoinAppUrl );
738
-
732
+ CFArrayRef listSnapshot = LSSharedFileListCopySnapshot (loginItems, nullptr );
733
+ bool res = ( findStartupItemInList (listSnapshot, loginItems, bitcoinAppUrl) != nullptr );
739
734
CFRelease (bitcoinAppUrl);
740
- return !!foundItem; // return boolified object
735
+ CFRelease (loginItems);
736
+ CFRelease (listSnapshot);
737
+ return res;
741
738
}
742
739
743
740
bool SetStartOnSystemStartup (bool fAutoStart )
@@ -748,7 +745,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
748
745
}
749
746
750
747
LSSharedFileListRef loginItems = LSSharedFileListCreate (nullptr , kLSSharedFileListSessionLoginItems , nullptr );
751
- LSSharedFileListItemRef foundItem = findStartupItemInList (loginItems, bitcoinAppUrl);
748
+ CFArrayRef listSnapshot = LSSharedFileListCopySnapshot (loginItems, nullptr );
749
+ LSSharedFileListItemRef foundItem = findStartupItemInList (listSnapshot, loginItems, bitcoinAppUrl);
752
750
753
751
if (fAutoStart && !foundItem) {
754
752
// add bitcoin app to startup item list
@@ -760,6 +758,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
760
758
}
761
759
762
760
CFRelease (bitcoinAppUrl);
761
+ CFRelease (loginItems);
762
+ CFRelease (listSnapshot);
763
763
return true ;
764
764
}
765
765
#pragma GCC diagnostic pop
0 commit comments