Merge branch 'charlesmchen/swiftExit'

pull/1/head
Matthew Chen 7 years ago
commit 64007e7d71

@ -240,8 +240,7 @@ static NSTimeInterval launchStartedAt;
[[UIApplication sharedApplication] scheduleLocalNotification:notification]; [[UIApplication sharedApplication] scheduleLocalNotification:notification];
[UIApplication.sharedApplication setApplicationIconBadgeNumber:1]; [UIApplication.sharedApplication setApplicationIconBadgeNumber:1];
[DDLog flushLog]; OWSFail(@"!isDatabasePasswordAccessible.");
exit(0);
} }
} }
@ -339,9 +338,7 @@ static NSTimeInterval launchStartedAt;
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[Pastelog submitLogsWithCompletion:^{ [Pastelog submitLogsWithCompletion:^{
OWSLogInfo(@"exiting after sharing debug logs."); OWSFail(@"exiting after sharing debug logs.");
[DDLog flushLog];
exit(0);
}]; }];
}]]; }]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController]; UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];

@ -233,7 +233,7 @@ NS_ASSUME_NONNULL_BEGIN
[self clearAllNotifications]; [self clearAllNotifications];
[DebugLogger.sharedLogger wipeLogs]; [DebugLogger.sharedLogger wipeLogs];
exit(0); OWSFail(@"App data reset.");
} }
+ (void)clearAllNotifications + (void)clearAllNotifications

@ -69,8 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
UIAlertAction *quitAction = [UIAlertAction actionWithTitle:@"Quit" UIAlertAction *quitAction = [UIAlertAction actionWithTitle:@"Quit"
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[DDLog flushLog]; OWSFail(@"Obsolete install.");
exit(0);
}]; }];
[alertController addAction:quitAction]; [alertController addAction:quitAction];

@ -153,17 +153,22 @@ NS_ASSUME_NONNULL_BEGIN
OWSCFailWithoutLogging(_messageFormat, ##__VA_ARGS__); \ OWSCFailWithoutLogging(_messageFormat, ##__VA_ARGS__); \
} while (NO) } while (NO)
void SwiftExit(NSString *message, const char *file, const char *function, int line);
#define OWSFail(_messageFormat, ...) \ #define OWSFail(_messageFormat, ...) \
do { \ do { \
OWSFailDebug(_messageFormat, ##__VA_ARGS__); \ OWSFailDebug(_messageFormat, ##__VA_ARGS__); \
exit(0); \ \
NSString *_message = [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]; \
SwiftExit(_message, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while (0) } while (0)
#define OWSCFail(_messageFormat, ...) \ #define OWSCFail(_messageFormat, ...) \
do { \ do { \
OWSCFailDebug(_messageFormat, ##__VA_ARGS__); \ OWSCFailDebug(_messageFormat, ##__VA_ARGS__); \
exit(0); \ \
NSString *_message = [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]; \
SwiftExit(_message, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while (NO) } while (NO)
// Avoids Clang analyzer warning: // Avoids Clang analyzer warning:

@ -3,7 +3,15 @@
// //
#import "OWSAsserts.h" #import "OWSAsserts.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
void SwiftExit(NSString *message, const char *file, const char *function, int line)
{
NSString *_file = [NSString stringWithFormat:@"%s", file];
NSString *_function = [NSString stringWithFormat:@"%s", function];
[OWSSwiftUtils owsFail:message file:_file function:_function line:line];
}
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -57,3 +57,15 @@ public func notImplemented(file: String = #file,
owsFail("Method not implemented.", file: file, function: function, line: line) owsFail("Method not implemented.", file: file, function: function, line: line)
} }
@objc public class OWSSwiftUtils: NSObject {
// This method can be invoked from Obj-C to exit the app.
@objc public class func owsFail(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) -> Never {
owsFailDebug(logMessage, file: file, function: function, line: line)
let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line)
fatalError(formattedMessage)
}
}

Loading…
Cancel
Save