Remove unneeded exception handler. Enable more sanatizer options.
This commit is contained in:
8 files changed
+6
-292
No files matched your search
@@ -1,52 +0,0 @@
|
||||
//
|
||||
// ExceptionAlertController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 20/10/2017.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
final class ExceptionAlertController: NSWindowController {
|
||||
|
||||
@IBOutlet var exceptionMessageTextField: NSTextField!
|
||||
@IBOutlet var exceptionBacktraceTextView: NSTextView!
|
||||
|
||||
private let exceptionMessage: String
|
||||
private let exceptionBacktrace: NSAttributedString
|
||||
|
||||
@objc init(exceptionMessage: String, exceptionBacktrace: NSAttributedString) {
|
||||
self.exceptionMessage = exceptionMessage
|
||||
self.exceptionBacktrace = exceptionBacktrace
|
||||
super.init(window: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override public var windowNibName: NSNib.Name? {
|
||||
return "ExceptionAlert"
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
exceptionMessageTextField.stringValue = exceptionMessage
|
||||
exceptionBacktraceTextView.textStorage?.append(exceptionBacktrace)
|
||||
}
|
||||
|
||||
@IBAction func btnCrashClicked(_ sender: Any) {
|
||||
window?.orderOut(self)
|
||||
NSApp.stopModal(withCode: NSApplication.ModalResponse.stop)
|
||||
}
|
||||
|
||||
@IBAction func btnContinueClicked(_ sender: Any) {
|
||||
window?.orderOut(self)
|
||||
NSApp.stopModal(withCode: NSApplication.ModalResponse.continue)
|
||||
}
|
||||
|
||||
@objc func runModal() -> NSApplication.ModalResponse {
|
||||
return NSApp.runModal(for: window!)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,7 +60,9 @@ class PrefsWindowController: NSWindowController, NSWindowDelegate {
|
||||
|
||||
"SBFileImporterImportMetadata": true,
|
||||
|
||||
"SBForceHvc1": true]
|
||||
"SBForceHvc1": true,
|
||||
"NSApplicationCrashOnException": true
|
||||
]
|
||||
|
||||
defaults.register(defaults: settings)
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
//
|
||||
// SBLogger.m
|
||||
// Subler
|
||||
//
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface SBApplication : NSApplication
|
||||
@end
|
||||
@@ -1,58 +0,0 @@
|
||||
//
|
||||
// SBLogger.m
|
||||
// Subler
|
||||
//
|
||||
|
||||
#import "SBApplication.h"
|
||||
#import "Subler-Swift.h"
|
||||
|
||||
@implementation SBApplication
|
||||
|
||||
static void CrashMyApplication()
|
||||
{
|
||||
*(char *)0x08 = 1;
|
||||
}
|
||||
|
||||
- (NSAttributedString *)_formattedExceptionBacktrace:(NSArray *)backtrace
|
||||
{
|
||||
NSMutableAttributedString *result = [[NSMutableAttributedString alloc] init];
|
||||
NSDictionary *textAttributes = @{NSForegroundColorAttributeName: NSColor.textColor,
|
||||
NSFontAttributeName: [NSFont fontWithName:@"Monaco" size:10]};
|
||||
|
||||
for (__strong NSString *s in backtrace)
|
||||
{
|
||||
s = [s stringByAppendingString:@"\n"];
|
||||
NSAttributedString *attrS = [[NSAttributedString alloc] initWithString:s];
|
||||
[result appendAttributedString:attrS];
|
||||
}
|
||||
[result addAttributes:textAttributes range:NSMakeRange(0, result.length)];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)reportException:(NSException *)exception
|
||||
{
|
||||
// NSApplication simply logs the exception to the console. We want to let the user know
|
||||
// when it happens in order to possibly prevent subsequent random crashes that are difficult to debug
|
||||
@try
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
// Create a string based on the exception
|
||||
NSString *exceptionMessage = [NSString stringWithFormat:@"%@\nReason: %@\nUser Info: %@", exception.name, exception.reason, exception.userInfo];
|
||||
|
||||
ExceptionAlertController *alertController = [[ExceptionAlertController alloc] initWithExceptionMessage:exceptionMessage exceptionBacktrace:[self _formattedExceptionBacktrace:exception.callStackSymbols]];
|
||||
|
||||
NSInteger result = [alertController runModal];
|
||||
if (result == NSModalResponseStop)
|
||||
{
|
||||
CrashMyApplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
@catch (NSException *e)
|
||||
{
|
||||
// Suppress any exceptions raised in the handling
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user