diff options
Diffstat (limited to 'SwifTools/Idle/MacOSXIdleQuerier.cpp')
| -rw-r--r-- | SwifTools/Idle/MacOSXIdleQuerier.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/SwifTools/Idle/MacOSXIdleQuerier.cpp b/SwifTools/Idle/MacOSXIdleQuerier.cpp index 6d6780b..89fa050 100644 --- a/SwifTools/Idle/MacOSXIdleQuerier.cpp +++ b/SwifTools/Idle/MacOSXIdleQuerier.cpp | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010 Isode Limited. | 2 | * Copyright (c) 2010-2018 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -10,6 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | #include <cassert> | 11 | #include <cassert> |
| 12 | #include <iostream> | 12 | #include <iostream> |
| 13 | #include <limits> | ||
| 14 | |||
| 13 | #include <boost/numeric/conversion/cast.hpp> | 15 | #include <boost/numeric/conversion/cast.hpp> |
| 14 | #include <CoreFoundation/CoreFoundation.h> | 16 | #include <CoreFoundation/CoreFoundation.h> |
| 15 | 17 | ||
| @@ -29,7 +31,12 @@ int MacOSXIdleQuerier::getIdleTimeSeconds() { | |||
| 29 | assert(result); | 31 | assert(result); |
| 30 | (void) result; | 32 | (void) result; |
| 31 | CFRelease(property); | 33 | CFRelease(property); |
| 32 | return boost::numeric_cast<int>(idle / 1000000000); | 34 | try { |
| 35 | return boost::numeric_cast<int>(idle / 1000000000); | ||
| 36 | } | ||
| 37 | catch (const boost::numeric::bad_numeric_cast&) { | ||
| 38 | return std::numeric_limits<int>::max(); | ||
| 39 | } | ||
| 33 | } | 40 | } |
| 34 | 41 | ||
| 35 | } | 42 | } |
Swift