summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-03-24 07:32:31 +0000
committerritsuka <[email protected]>2015-03-24 07:32:31 +0000
commit467cc4ed93771aae1d6dca546758dffe5312899b (patch)
tree7e095561b8f34da6df9ce7c922478adcea1a3f80 /macosx
parent4a700442ef0cff37f4419faf5045caec59d8a126 (diff)
MacGui: add an alert window to show the exceptions not handled. Hopefully it will make it easier for users to report this kind of issue.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7010 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r--macosx/English.lproj/ExceptionAlert.xib126
-rw-r--r--macosx/HBApplication.h11
-rw-r--r--macosx/HBApplication.m63
-rw-r--r--macosx/HBExceptionAlertController.h25
-rw-r--r--macosx/HBExceptionAlertController.m33
-rw-r--r--macosx/HandBrake.xcodeproj/project.pbxproj24
-rw-r--r--macosx/Info.plist.m42
7 files changed, 283 insertions, 1 deletions
diff --git a/macosx/English.lproj/ExceptionAlert.xib b/macosx/English.lproj/ExceptionAlert.xib
new file mode 100644
index 000000000..2b0c747a3
--- /dev/null
+++ b/macosx/English.lproj/ExceptionAlert.xib
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7525" systemVersion="14D113c" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" promptedForUpgradeToXcode5="NO">
+ <dependencies>
+ <deployment identifier="macosx"/>
+ <development version="6100" identifier="xcode"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7525"/>
+ </dependencies>
+ <objects>
+ <customObject id="-2" userLabel="File's Owner" customClass="MyExceptionAlertController">
+ <connections>
+ <outlet property="window" destination="1" id="17"/>
+ </connections>
+ </customObject>
+ <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+ <customObject id="-3" userLabel="Application"/>
+ <window title="Internal Error" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="1">
+ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+ <rect key="contentRect" x="196" y="127" width="636" height="383"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
+ <value key="minSize" type="size" width="636" height="383"/>
+ <view key="contentView" id="2">
+ <rect key="frame" x="0.0" y="0.0" width="636" height="383"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <imageView id="3">
+ <rect key="frame" x="20" y="302" width="70" height="61"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+ <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSApplicationIcon" id="4"/>
+ </imageView>
+ <textField verticalHuggingPriority="750" id="9">
+ <rect key="frame" x="95" y="323" width="524" height="40"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+ <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="An internal error has occurred. You can choose to continue in an unstable state, or crash." id="10">
+ <font key="font" metaFont="systemBold"/>
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ <textField verticalHuggingPriority="750" id="11">
+ <rect key="frame" x="95" y="282" width="339" height="41"/>
+ <autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
+ <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Reason contents go here." id="12">
+ <font key="font" metaFont="smallSystem"/>
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ <connections>
+ <binding destination="-2" name="value" keyPath="exceptionMessage" id="27">
+ <dictionary key="options">
+ <bool key="NSAllowsEditingMultipleValuesSelection" value="NO"/>
+ </dictionary>
+ </binding>
+ </connections>
+ </textField>
+ <button verticalHuggingPriority="750" id="13">
+ <rect key="frame" x="418" y="12" width="96" height="32"/>
+ <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+ <buttonCell key="cell" type="push" title="Crash" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="14">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="system"/>
+ <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+ </buttonCell>
+ <connections>
+ <action selector="btnCrashClicked:" target="-2" id="24"/>
+ </connections>
+ </button>
+ <button verticalHuggingPriority="750" id="15">
+ <rect key="frame" x="526" y="12" width="97" height="32"/>
+ <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+ <buttonCell key="cell" type="push" title="Continue" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="16">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="system"/>
+ <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+ </buttonCell>
+ <connections>
+ <action selector="btnContinueClicked:" target="-2" id="23"/>
+ </connections>
+ </button>
+ <scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="19">
+ <rect key="frame" x="20" y="60" width="596" height="206"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <clipView key="contentView" id="RBQ-rK-0Rs">
+ <rect key="frame" x="1" y="1" width="594" height="204"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <textView importsGraphics="NO" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="22">
+ <rect key="frame" x="0.0" y="0.0" width="594" height="204"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ <size key="minSize" width="594" height="204"/>
+ <size key="maxSize" width="759" height="10000000"/>
+ <color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+ <size key="minSize" width="594" height="204"/>
+ <size key="maxSize" width="759" height="10000000"/>
+ <connections>
+ <binding destination="-2" name="attributedString" keyPath="exceptionBacktrace" id="28"/>
+ </connections>
+ </textView>
+ </subviews>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ </clipView>
+ <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="21">
+ <rect key="frame" x="-100" y="-100" width="87" height="18"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </scroller>
+ <scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="20">
+ <rect key="frame" x="579" y="1" width="16" height="204"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </scroller>
+ </scrollView>
+ </subviews>
+ </view>
+ <connections>
+ <outlet property="initialFirstResponder" destination="13" id="29"/>
+ </connections>
+ <point key="canvasLocation" x="256" y="550.5"/>
+ </window>
+ </objects>
+ <resources>
+ <image name="NSApplicationIcon" width="128" height="128"/>
+ </resources>
+</document>
diff --git a/macosx/HBApplication.h b/macosx/HBApplication.h
new file mode 100644
index 000000000..2fbeab833
--- /dev/null
+++ b/macosx/HBApplication.h
@@ -0,0 +1,11 @@
+/* HBApplication.h $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import <Cocoa/Cocoa.h>
+
+@interface HBApplication : NSApplication
+
+@end
diff --git a/macosx/HBApplication.m b/macosx/HBApplication.m
new file mode 100644
index 000000000..d725b1bad
--- /dev/null
+++ b/macosx/HBApplication.m
@@ -0,0 +1,63 @@
+/* HBApplication.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import "HBApplication.h"
+#import "HBExceptionAlertController.h"
+#import "HBUtilities.h"
+
+@implementation HBApplication
+
+static void CrashMyApplication()
+{
+ *(char *)0x08 = 1;
+}
+
+- (NSAttributedString *)_formattedExceptionBacktrace:(NSArray *)backtrace
+{
+ NSMutableAttributedString *result = [[NSMutableAttributedString alloc] init];
+ for (__strong NSString *s in backtrace)
+ {
+ s = [s stringByAppendingString:@"\n"];
+ NSAttributedString *attrS = [[NSAttributedString alloc] initWithString:s];
+ [result appendAttributedString:attrS];
+ }
+ [result addAttribute:NSFontAttributeName value:[NSFont fontWithName:@"Monaco" size:10] 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];
+ // Always log to console for history
+
+ [HBUtilities writeToActivityLog:"Exception raised:\n%s", exceptionMessage.UTF8String];
+ [HBUtilities writeToActivityLog:"Backtrace:\n%s", exception.callStackSymbols.description.UTF8String];
+
+ HBExceptionAlertController *alertController = [[HBExceptionAlertController alloc] init];
+ alertController.exceptionMessage = exceptionMessage;
+ alertController.exceptionBacktrace = [self _formattedExceptionBacktrace:exception.callStackSymbols];
+
+ NSInteger result = [alertController runModal];
+ if (result == HBExceptionAlertControllerResultCrash)
+ {
+ CrashMyApplication();
+ }
+ }
+ }
+ @catch (NSException *e)
+ {
+ // Suppress any exceptions raised in the handling
+ }
+}
+
+@end
diff --git a/macosx/HBExceptionAlertController.h b/macosx/HBExceptionAlertController.h
new file mode 100644
index 000000000..aaf49647c
--- /dev/null
+++ b/macosx/HBExceptionAlertController.h
@@ -0,0 +1,25 @@
+/* HBExceptionAlertController.h $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import <Cocoa/Cocoa.h>
+
+typedef NS_ENUM(NSUInteger, HBExceptionAlertControllerResult) {
+ HBExceptionAlertControllerResultCrash,
+ HBExceptionAlertControllerResultContinue,
+};
+
+@interface HBExceptionAlertController : NSWindowController
+
+// Properties are used by bindings
+@property (copy) NSString *exceptionMessage;
+@property (copy) NSAttributedString *exceptionBacktrace;
+
+- (IBAction)btnCrashClicked:(id)sender;
+- (IBAction)btnContinueClicked:(id)sender;
+
+- (NSInteger)runModal;
+
+@end
diff --git a/macosx/HBExceptionAlertController.m b/macosx/HBExceptionAlertController.m
new file mode 100644
index 000000000..001794cac
--- /dev/null
+++ b/macosx/HBExceptionAlertController.m
@@ -0,0 +1,33 @@
+/* HBExceptionAlertController.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import "HBExceptionAlertController.h"
+
+@implementation HBExceptionAlertController
+
+- (id)init
+{
+ return [self initWithWindowNibName:@"ExceptionAlert"];
+}
+
+- (NSInteger)runModal
+{
+ return [NSApp runModalForWindow:self.window];
+}
+
+- (IBAction)btnCrashClicked:(id)sender
+{
+ [self.window orderOut:nil];
+ [NSApp stopModalWithCode:HBExceptionAlertControllerResultCrash];
+}
+
+- (IBAction)btnContinueClicked:(id)sender
+{
+ [self.window orderOut:nil];
+ [NSApp stopModalWithCode:HBExceptionAlertControllerResultContinue];
+}
+
+@end
diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj
index d4581b9b5..a9a07e89a 100644
--- a/macosx/HandBrake.xcodeproj/project.pbxproj
+++ b/macosx/HandBrake.xcodeproj/project.pbxproj
@@ -150,6 +150,9 @@
A955128B1A320B02001BFC6F /* libjansson.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A95512881A320A12001BFC6F /* libjansson.a */; };
A9597A2A1A49749D00007771 /* HBRange+UIAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A9597A291A49749D00007771 /* HBRange+UIAdditions.m */; };
A967E4BA1A16768200DF1DFC /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = A967E4B91A16768200DF1DFC /* [email protected] */; };
+ A9706CB41AC1436F00BAEAA8 /* HBApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = A9706CB31AC1436F00BAEAA8 /* HBApplication.m */; };
+ A9706CB71AC1437800BAEAA8 /* HBExceptionAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9706CB61AC1437800BAEAA8 /* HBExceptionAlertController.m */; };
+ A9706CBA1AC1452800BAEAA8 /* ExceptionAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9706CB81AC1452800BAEAA8 /* ExceptionAlert.xib */; };
A971281F1A2C75180088C076 /* HBTitle.m in Sources */ = {isa = PBXBuildFile; fileRef = A971281E1A2C75180088C076 /* HBTitle.m */; };
A983494F1A9A64B80059CB94 /* presets.plist in Resources */ = {isa = PBXBuildFile; fileRef = A983494E1A9A64B80059CB94 /* presets.plist */; };
A98C29C41977B10600AF5DED /* HBLanguagesSelection.m in Sources */ = {isa = PBXBuildFile; fileRef = A98C29C31977B10600AF5DED /* HBLanguagesSelection.m */; };
@@ -417,6 +420,11 @@
A9597A281A49749D00007771 /* HBRange+UIAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HBRange+UIAdditions.h"; sourceTree = "<group>"; };
A9597A291A49749D00007771 /* HBRange+UIAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "HBRange+UIAdditions.m"; sourceTree = "<group>"; };
A967E4B91A16768200DF1DFC /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
+ A9706CB21AC1436F00BAEAA8 /* HBApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBApplication.h; sourceTree = "<group>"; };
+ A9706CB31AC1436F00BAEAA8 /* HBApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBApplication.m; sourceTree = "<group>"; };
+ A9706CB51AC1437800BAEAA8 /* HBExceptionAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBExceptionAlertController.h; sourceTree = "<group>"; };
+ A9706CB61AC1437800BAEAA8 /* HBExceptionAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBExceptionAlertController.m; sourceTree = "<group>"; };
+ A9706CB91AC1452800BAEAA8 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = ExceptionAlert.xib; sourceTree = "<group>"; };
A971281D1A2C75180088C076 /* HBTitle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBTitle.h; sourceTree = "<group>"; };
A971281E1A2C75180088C076 /* HBTitle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBTitle.m; sourceTree = "<group>"; };
A983494E1A9A64B80059CB94 /* presets.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = presets.plist; sourceTree = "<group>"; };
@@ -700,6 +708,10 @@
A952392E199A647F00588AEF /* Presets */,
A9AA44781970664A00D7DEFC /* HBUtilities.h */,
A9AA44791970664A00D7DEFC /* HBUtilities.m */,
+ A9706CB21AC1436F00BAEAA8 /* HBApplication.h */,
+ A9706CB31AC1436F00BAEAA8 /* HBApplication.m */,
+ A9706CB51AC1437800BAEAA8 /* HBExceptionAlertController.h */,
+ A9706CB61AC1437800BAEAA8 /* HBExceptionAlertController.m */,
A98F00771A972007001C2298 /* Output Redirect */,
A9E66D6E1A67A2A8007B641D /* HBDistributedArray.h */,
A9E66D6F1A67A2A8007B641D /* HBDistributedArray.m */,
@@ -823,6 +835,7 @@
273F218414ADDDA10021BE6D /* PictureSettings.xib */,
273F218614ADDDA10021BE6D /* Preferences.xib */,
273F218814ADDDA10021BE6D /* Queue.xib */,
+ A9706CB81AC1452800BAEAA8 /* ExceptionAlert.xib */,
);
path = English.lproj;
sourceTree = "<group>";
@@ -1231,6 +1244,7 @@
D2BCB11A16F5152C0084604C /* [email protected] in Resources */,
D2BCB11B16F5152C0084604C /* [email protected] in Resources */,
D2BCB12316F5154E0084604C /* settings.png in Resources */,
+ A9706CBA1AC1452800BAEAA8 /* ExceptionAlert.xib in Resources */,
D2BCB12416F5154E0084604C /* showqueue.png in Resources */,
D2BCB12516F5154E0084604C /* [email protected] in Resources */,
D2BCB12616F5154E0084604C /* source.png in Resources */,
@@ -1263,6 +1277,7 @@
A98C29C41977B10600AF5DED /* HBLanguagesSelection.m in Sources */,
A9BB0F2719A0ECE40079F1C1 /* HBHUDButtonCell.m in Sources */,
A932E273198834130047D13E /* HBAudioDefaults.m in Sources */,
+ A9706CB71AC1437800BAEAA8 /* HBExceptionAlertController.m in Sources */,
A92268781A6E555500A8D5C5 /* HBAppDelegate.m in Sources */,
A91806711A4807B000FC9BED /* HBRange.m in Sources */,
A9DEC8771A23C88D00C79B48 /* HBVideo.m in Sources */,
@@ -1299,6 +1314,7 @@
A90A0CAF1988D57200DA65CE /* HBAudioTrackPreset.m in Sources */,
A91017B41A64440A00039BFB /* HBSubtitles.m in Sources */,
273F20BA14ADBE670021BE6D /* HBPictureController.m in Sources */,
+ A9706CB41AC1436F00BAEAA8 /* HBApplication.m in Sources */,
A9CF25F71990D6820023F727 /* HBPresetsViewController.m in Sources */,
A9537BF91A48AC9000141102 /* HBFilters+UIAdditions.m in Sources */,
273F20BE14ADC09F0021BE6D /* main.mm in Sources */,
@@ -1421,6 +1437,14 @@
name = Video.xib;
sourceTree = "<group>";
};
+ A9706CB81AC1452800BAEAA8 /* ExceptionAlert.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ A9706CB91AC1452800BAEAA8 /* English */,
+ );
+ name = ExceptionAlert.xib;
+ sourceTree = "<group>";
+ };
A9935211196F38A70069C6B7 /* ChaptersTitles.xib */ = {
isa = PBXVariantGroup;
children = (
diff --git a/macosx/Info.plist.m4 b/macosx/Info.plist.m4
index 9c490e6a6..a75471578 100644
--- a/macosx/Info.plist.m4
+++ b/macosx/Info.plist.m4
@@ -63,7 +63,7 @@ All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
- <string>NSApplication</string>
+ <string>HBApplication</string>
<key>SUFeedURL</key>
<string>__HB_url_appcast</string>
</dict>