diff --git a/Base.lproj/ExceptionAlert.xib b/Base.lproj/ExceptionAlert.xib deleted file mode 100644 index c7120d2..0000000 --- a/Base.lproj/ExceptionAlert.xib +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Classes/ExceptionAlertController.swift b/Classes/ExceptionAlertController.swift deleted file mode 100644 index 3597246..0000000 --- a/Classes/ExceptionAlertController.swift +++ /dev/null @@ -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!) - } - -} diff --git a/Classes/PrefsWindowController.swift b/Classes/PrefsWindowController.swift index 7bf0136..e920f00 100644 --- a/Classes/PrefsWindowController.swift +++ b/Classes/PrefsWindowController.swift @@ -60,7 +60,9 @@ class PrefsWindowController: NSWindowController, NSWindowDelegate { "SBFileImporterImportMetadata": true, - "SBForceHvc1": true] + "SBForceHvc1": true, + "NSApplicationCrashOnException": true + ] defaults.register(defaults: settings) } diff --git a/Classes/SBApplication.h b/Classes/SBApplication.h deleted file mode 100644 index 3eadb59..0000000 --- a/Classes/SBApplication.h +++ /dev/null @@ -1,10 +0,0 @@ -// -// SBLogger.m -// Subler -// -// - -#import - -@interface SBApplication : NSApplication -@end diff --git a/Classes/SBApplication.m b/Classes/SBApplication.m deleted file mode 100644 index 46bea75..0000000 --- a/Classes/SBApplication.m +++ /dev/null @@ -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 diff --git a/Info.plist b/Info.plist index 15e41ef..ca3af89 100644 --- a/Info.plist +++ b/Info.plist @@ -154,7 +154,7 @@ NSMainNibFile MainMenu NSPrincipalClass - SBApplication + NSApplication OSAScriptingDefinition Queue.sdef SUAllowsAutomaticUpdates diff --git a/Subler.xcodeproj/project.pbxproj b/Subler.xcodeproj/project.pbxproj index 81efb6e..f6d9a83 100644 --- a/Subler.xcodeproj/project.pbxproj +++ b/Subler.xcodeproj/project.pbxproj @@ -106,7 +106,6 @@ A9BA1AF31DBF7DD800FD0B38 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9BA1AF51DBF7DD800FD0B38 /* Localizable.strings */; }; A9BC410818D9ABC000F8C92C /* QueueItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9BC410618D9ABC000F8C92C /* QueueItem.xib */; }; A9BE561B220307F100FF6BE3 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE561A220307F100FF6BE3 /* Utilities.swift */; }; - A9C09C7C1F99F460007939EE /* ExceptionAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C09C7B1F99F460007939EE /* ExceptionAlertController.swift */; }; A9C09C981F99F971007939EE /* ExpandedTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C09C971F99F971007939EE /* ExpandedTableView.swift */; }; A9C09C9A1F9A0808007939EE /* EmptyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C09C991F9A0808007939EE /* EmptyViewController.swift */; }; A9C09C9C1F9A08A9007939EE /* MultiSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C09C9B1F9A08A9007939EE /* MultiSelectViewController.swift */; }; @@ -121,8 +120,6 @@ A9D4B8671C05BD04007845C4 /* SBChapterSearch.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9D4B8651C05BD04007845C4 /* SBChapterSearch.xib */; }; A9D64527202CA92400BA172B /* SaveOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D64525202CA92400BA172B /* SaveOptions.swift */; }; A9DA03E322A0211C0056AE7B /* OCRPrefsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DA03E122A0211C0056AE7B /* OCRPrefsViewController.swift */; }; - A9DA3B9C1B918D5C00F1E40C /* SBApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = A9DA3B991B918D5C00F1E40C /* SBApplication.m */; }; - A9DA3BA31B918D6F00F1E40C /* ExceptionAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9DA3BA11B918D6F00F1E40C /* ExceptionAlert.xib */; }; A9E97F141F274F1100DBA586 /* iTunesStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E97F131F274F1100DBA586 /* iTunesStore.swift */; }; A9ECA0532029948900D5F30C /* OffsetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9ECA0512029948900D5F30C /* OffsetViewController.swift */; }; A9ECA0572029A10B00D5F30C /* DocumentWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9ECA0592029A10B00D5F30C /* DocumentWindowController.xib */; }; @@ -245,7 +242,6 @@ A924A51A1D4B9E66008301A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/PrefsWindowController.xib; sourceTree = ""; }; A924A51B1D4B9E67008301A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SBActivityWindow.xib; sourceTree = ""; }; A924A51C1D4B9E67008301A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MediaTagsController.xib; sourceTree = ""; }; - A924A51D1D4B9E67008301A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ExceptionAlert.xib; sourceTree = ""; }; A924A51F1D4B9E93008301A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MetadataPrefsViewController.xib; sourceTree = ""; }; A925AA7B18378D7800BE84D4 /* MP42Foundation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MP42Foundation.xcodeproj; path = MP42Foundation/MP42Foundation.xcodeproj; sourceTree = ""; }; A92AD0151F3482350082892E /* NetworkUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = NetworkUtilities.swift; path = Classes/NetworkUtilities.swift; sourceTree = ""; }; @@ -333,12 +329,10 @@ A9BA1AE01DBF773700FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/QueueItem.strings; sourceTree = ""; }; A9BA1AE21DBF773700FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/SBActivityWindow.strings; sourceTree = ""; }; A9BA1AE31DBF773700FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/MediaTagsController.strings; sourceTree = ""; }; - A9BA1AE41DBF773700FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/ExceptionAlert.strings; sourceTree = ""; }; A9BA1AE51DBF773700FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = it; path = it.lproj/Credits.rtf; sourceTree = ""; }; A9BA1AE61DBF773700FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/InfoPlist.strings; sourceTree = ""; }; A9BA1AF41DBF7DD800FD0B38 /* it */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = ""; }; A9BE561A220307F100FF6BE3 /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Utilities.swift; path = Classes/Utilities.swift; sourceTree = ""; }; - A9C09C7B1F99F460007939EE /* ExceptionAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ExceptionAlertController.swift; path = Classes/ExceptionAlertController.swift; sourceTree = ""; }; A9C09C971F99F971007939EE /* ExpandedTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ExpandedTableView.swift; path = Classes/ExpandedTableView.swift; sourceTree = ""; }; A9C09C991F9A0808007939EE /* EmptyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = EmptyViewController.swift; path = Classes/PropertyView/EmptyViewController.swift; sourceTree = ""; }; A9C09C9B1F9A08A9007939EE /* MultiSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MultiSelectViewController.swift; path = Classes/PropertyView/MultiSelectViewController.swift; sourceTree = ""; }; @@ -351,8 +345,6 @@ A9CBAB1D1F29C083001C26B3 /* MetadataImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MetadataImporter.swift; path = Classes/MetadataImporters/MetadataImporter.swift; sourceTree = ""; }; A9D64525202CA92400BA172B /* SaveOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SaveOptions.swift; path = Classes/SaveOptions.swift; sourceTree = ""; }; A9DA03E122A0211C0056AE7B /* OCRPrefsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = OCRPrefsViewController.swift; path = Classes/OCRPrefsViewController.swift; sourceTree = ""; }; - A9DA3B991B918D5C00F1E40C /* SBApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBApplication.m; path = Classes/SBApplication.m; sourceTree = ""; }; - A9DA3BA01B918D6200F1E40C /* SBApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBApplication.h; path = Classes/SBApplication.h; sourceTree = ""; }; A9E97F131F274F1100DBA586 /* iTunesStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = iTunesStore.swift; path = Classes/MetadataImporters/iTunesStore.swift; sourceTree = ""; }; A9E9E5291FB21B4000BCC49D /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/FileImportController.strings; sourceTree = ""; }; A9ECA0512029948900D5F30C /* OffsetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = OffsetViewController.swift; path = Classes/OffsetViewController.swift; sourceTree = ""; }; @@ -549,11 +541,7 @@ children = ( A956CE641F99E5BB00093992 /* ActivityWindowController.swift */, A9C5FA7219FA2FEC0051F3FF /* SBActivityWindow.xib */, - A9C09C7B1F99F460007939EE /* ExceptionAlertController.swift */, - A9DA3BA11B918D6F00F1E40C /* ExceptionAlert.xib */, A956CE6A1F99EAAD00093992 /* Logger.swift */, - A9DA3BA01B918D6200F1E40C /* SBApplication.h */, - A9DA3B991B918D5C00F1E40C /* SBApplication.m */, ); name = "Activity Log"; sourceTree = ""; @@ -782,7 +770,6 @@ A90300C81DAE72C4008237D8 /* PresetPrefsViewController.xib in Resources */, A984DB740F52DD4B001A20B2 /* dsa_pub.pem in Resources */, A9C5FA7419FA2FEC0051F3FF /* SBActivityWindow.xib in Resources */, - A9DA3BA31B918D6F00F1E40C /* ExceptionAlert.xib in Resources */, A90B023B10F3290A000416F3 /* PrefsWindowController.xib in Resources */, A9AB486417F0AEFD000AA72E /* ChapterView.xib in Resources */, A9AB486817F0AEFD000AA72E /* VideoView.xib in Resources */, @@ -829,7 +816,6 @@ A90B094C235614D200F1B191 /* AppleTV.swift in Sources */, A97D99DA22A0240C001FA3A7 /* OCRManager.swift in Sources */, A9DA03E322A0211C0056AE7B /* OCRPrefsViewController.swift in Sources */, - A9C09C7C1F99F460007939EE /* ExceptionAlertController.swift in Sources */, A9A91B5D1FB6FBB700250D93 /* ChapterViewController.swift in Sources */, A9676A301FB6E85300C1E300 /* LanguageTransformer.swift in Sources */, A9EFB8CC21FF40C500129FDD /* QueueItem.swift in Sources */, @@ -877,7 +863,6 @@ A9C31E602029A80F00CEF474 /* AdvancedPrefsViewController.swift in Sources */, A979B3862025C8BF00468362 /* DocumentWindowController.swift in Sources */, A9067A0C1F3CA4E6008011DC /* MetadataPrefsViewController.swift in Sources */, - A9DA3B9C1B918D5C00F1E40C /* SBApplication.m in Sources */, A9CBAB1E1F29C083001C26B3 /* MetadataImporter.swift in Sources */, A92BBAB41F557CC0007EA182 /* PresetEditorViewController.swift in Sources */, A983E80B22365B5400221BAE /* MovieViewController.swift in Sources */, @@ -1171,15 +1156,6 @@ name = SBChapterSearch.xib; sourceTree = ""; }; - A9DA3BA11B918D6F00F1E40C /* ExceptionAlert.xib */ = { - isa = PBXVariantGroup; - children = ( - A924A51D1D4B9E67008301A7 /* Base */, - A9BA1AE41DBF773700FD0B38 /* it */, - ); - name = ExceptionAlert.xib; - sourceTree = ""; - }; A9ECA0592029A10B00D5F30C /* DocumentWindowController.xib */ = { isa = PBXVariantGroup; children = ( @@ -1338,6 +1314,7 @@ CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; @@ -1411,6 +1388,7 @@ CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; diff --git a/it.lproj/ExceptionAlert.strings b/it.lproj/ExceptionAlert.strings deleted file mode 100644 index 8c29ae9..0000000 --- a/it.lproj/ExceptionAlert.strings +++ /dev/null @@ -1,6 +0,0 @@ -/* Class = "NSWindow"; title = "Internal Error"; ObjectID = "1"; */ -"1.title" = "Errore interno"; - -/* Class = "NSButtonCell"; title = "Continue"; ObjectID = "16"; */ -"16.title" = "Continua"; -