1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

macOS/iOS: Fix unguarded availability warnings

This commit is contained in:
Tom Poole 2022-04-11 13:50:34 +01:00
parent e984395b1d
commit db3c6e6216
27 changed files with 220 additions and 177 deletions

View file

@ -28,12 +28,21 @@ namespace juce
class ScopedLowPowerModeDisabler::Pimpl
{
public:
Pimpl() = default;
~Pimpl() { [[NSProcessInfo processInfo] endActivity: activity]; }
Pimpl()
{
if (@available (macOS 10.9, *))
activity = [[NSProcessInfo processInfo] beginActivityWithOptions: NSActivityUserInitiatedAllowingIdleSystemSleep
reason: @"App must remain in high-power mode"];
}
~Pimpl()
{
if (@available (macOS 10.9, *))
[[NSProcessInfo processInfo] endActivity: activity];
}
private:
id activity { [[NSProcessInfo processInfo] beginActivityWithOptions: NSActivityUserInitiatedAllowingIdleSystemSleep
reason: @"App must remain in high-power mode"] };
id activity;
JUCE_DECLARE_NON_COPYABLE (Pimpl)
JUCE_DECLARE_NON_MOVEABLE (Pimpl)