gnome-subtitles r1035 - in trunk/src/GnomeSubtitles: Core Execution
- From: pcastro svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-subtitles r1035 - in trunk/src/GnomeSubtitles: Core Execution
- Date: Sun, 13 Jul 2008 17:50:22 +0000 (UTC)
Author: pcastro
Date: Sun Jul 13 17:50:22 2008
New Revision: 1035
URL: http://svn.gnome.org/viewvc/gnome-subtitles?rev=1035&view=rev
Log:
Use GLib.ExceptionManager.UnhandledException to catch unhandled exceptions in the application, and report them.
Modified:
trunk/src/GnomeSubtitles/Core/Base.cs
trunk/src/GnomeSubtitles/Execution/Executable.cs
Modified: trunk/src/GnomeSubtitles/Core/Base.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Core/Base.cs (original)
+++ trunk/src/GnomeSubtitles/Core/Base.cs Sun Jul 13 17:50:22 2008
@@ -109,23 +109,13 @@
/* Public methods */
- /// <summary>Runs the main GUI, after initialization.</summary>
- /// <returns>Whether running the application completed without fatal errors.</returns>
- public static bool Run (ExecutionContext executionContext) {
- try {
- if (!Init(executionContext))
- throw new Exception("The Base environment was already initialized.");
+ /// <summary>Runs the main GUI, after initialization.</summary>
+ public static void Run (ExecutionContext executionContext) {
+ if (!Init(executionContext))
+ throw new Exception("The Base environment was already initialized.");
- ui.Start();
- executionContext.RunProgram();
-
- return true;
- }
- catch (Exception exception) {
- Kill();
- BugReporter.Report(exception);
- return false;
- }
+ ui.Start();
+ executionContext.RunProgram();
}
/// <summary>Quits the program.</summary>
@@ -133,6 +123,12 @@
executionContext.QuitProgram();
}
+ public static void Kill () {
+ clipboards.WatchPrimaryChanges = false;
+ executionContext.QuitProgram();
+ ui.Kill();
+ }
+
public static void CreateDocumentNew (string path) {
bool wasLoaded = IsDocumentLoaded;
document = new Document(path, wasLoaded);
@@ -188,18 +184,6 @@
return true;
}
-
- /// <summary>Kills the window in the most quick and unfriendly way.</summary>
- private static void Kill () {
- try {
- clipboards.WatchPrimaryChanges = false;
- executionContext.QuitProgram();
- ui.Kill();
- }
- catch (Exception) {
- ; //Nothing to do if there were errors while killing the window
- }
- }
}
Modified: trunk/src/GnomeSubtitles/Execution/Executable.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Execution/Executable.cs (original)
+++ trunk/src/GnomeSubtitles/Execution/Executable.cs Sun Jul 13 17:50:22 2008
@@ -17,6 +17,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+using GLib;
using GnomeSubtitles.Core;
using System;
using System.Runtime.InteropServices;
@@ -65,12 +66,39 @@
}
public static void Main (string[] args) {
+ ExceptionManager.UnhandledException += OnUnhandledException;
+
ExecutionContext executionContext = new ExecutionContext(args);
SetProcessName(executionContext.ExecutableName);
Base.Run(executionContext);
}
#endregion
+
+ #region Private members
+
+ /// <summary>Kills the window in the most quick and unfriendly way.</summary>
+ private static void Kill () {
+ try {
+ Base.Kill();
+ }
+ catch (Exception) {
+ ; //Nothing to do if there were errors while killing the window
+ }
+ }
+
+ #endregion
+
+ #region Events
+
+ private static void OnUnhandledException (UnhandledExceptionArgs args) {
+ if (args.ExceptionObject is Exception)
+ BugReporter.Report(args.ExceptionObject as Exception);
+
+ Kill();
+ }
+
+ #endregion
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]