[commit] r1100 - trunk/GME/MgaUtil

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Nov 24 13:39:55 CST 2010


Author: ksmyth
Date: Wed Nov 24 13:39:55 2010
New Revision: 1100

Log:
Fix GME-318: invoke CrashRpt if an interpreter crashes when invoked via GME and show warning. Just show warning if invoked via MgaLauncher outside of GME.

Modified:
   trunk/GME/MgaUtil/MgaLauncher.cpp
   trunk/GME/MgaUtil/MgaUtil.vcxproj

Modified: trunk/GME/MgaUtil/MgaLauncher.cpp
==============================================================================
--- trunk/GME/MgaUtil/MgaLauncher.cpp	Wed Nov 24 13:38:25 2010	(r1099)
+++ trunk/GME/MgaUtil/MgaLauncher.cpp	Wed Nov 24 13:39:55 2010	(r1100)
@@ -10,6 +10,13 @@
 #include "AnnotationBrowserDlg.h"
 #include "CommonComponent.h"
 
+#include "CrashRpt.h"
+#ifdef _DEBUG
+#pragma comment(lib, "CrashRptd.lib")
+#else
+#pragma comment(lib, "CrashRpt.lib")
+#endif
+
 
 /* Deprecated Web based help
 #define GME_UMAN_HOME				"http://www.isis.vanderbilt.edu/projects/GME/Doc/UsersManual/"
@@ -635,6 +642,24 @@
 	COMCATCH(;)
 }
 
+static int __stdcall nopExceptionFilter(unsigned int code, struct _EXCEPTION_POINTERS* ep) {
+	return EXCEPTION_EXECUTE_HANDLER;
+}
+
+// returns 0 if an exception was caught
+bool __stdcall InvokeExWithCrashRpt(IMgaComponentEx* compex, IMgaProject* project, IMgaFCO* focusobj, IMgaFCOs* selectedobjs, long param, HRESULT& hr) {
+	__try {
+		__try {
+			hr = compex->InvokeEx(project, focusobj, selectedobjs, param);
+		} __except(crExceptionFilter(GetExceptionCode(), GetExceptionInformation())) {
+			return 0;
+		}
+		// If run outside of GME, CrashRpt will not be set up, and crExceptionFilter will return EXCEPTION_CONTINUE_SEARCH
+	} __except(nopExceptionFilter(GetExceptionCode(), GetExceptionInformation())) {
+		return 0;
+	}
+	return 1;
+}
 
 STDMETHODIMP CMgaLauncher::RunComponent(BSTR progid, IMgaProject *project, IMgaFCO *focusobj, IMgaFCOs *selectedobjs, long param)
 {
@@ -744,8 +769,16 @@
 					try	{
 						COMTHROW(component->Initialize(project));
 						CComQIPtr<IMgaComponentEx> compex = component;
-						if(compex) {
-							COMTHROW(compex->InvokeEx(project, focusobj, CComQIPtr<IMgaFCOs>(selectedobjs), param));
+						if (compex) {
+							HRESULT hr;
+							if (!InvokeExWithCrashRpt(compex, project, focusobj, selectedobjs, param, hr)) {
+								project->AbortTransaction();
+								AfxMessageBox("An error has occurred in component " + compname + ".\n"
+									"GME may not be in a stable state.\n"
+									"Please save your work and restart GME.");
+							} else {
+								COMTHROW(hr);
+							}
 						}
 						else {
 							CComPtr<IMgaTerritory> terr;
@@ -763,13 +796,15 @@
 						}
 					}
 					catch(hresult_exception &e)	{
+						project->AbortTransaction();
 						DisplayError("Component error", e.hr);
 					}
 					catch(...)
 					{
-						AfxMessageBox("An application error has occurred in component " + compname + ".\n"
-							"The system might not be in a stable state any more.\n"
-							"Please save your work and restart the GME.");
+						project->AbortTransaction();
+						AfxMessageBox("An error has occurred in component " + compname + ".\n"
+							"GME may not be in a stable state.\n"
+							"Please save your work and restart GME.");
 					} 
 				}
 				else {		// running unprotected

Modified: trunk/GME/MgaUtil/MgaUtil.vcxproj
==============================================================================
--- trunk/GME/MgaUtil/MgaUtil.vcxproj	Wed Nov 24 13:38:25 2010	(r1099)
+++ trunk/GME/MgaUtil/MgaUtil.vcxproj	Wed Nov 24 13:39:55 2010	(r1100)
@@ -36,11 +36,11 @@
   </ImportGroup>
   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\CrashRpt.props" />
   </ImportGroup>
   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\CrashRpt.props" />
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup>
@@ -309,4 +309,4 @@
       <UserProperties RESOURCE_FILE="MgaUtil.rc" />
     </VisualStudio>
   </ProjectExtensions>
-</Project>
+</Project>
\ No newline at end of file


More information about the gme-commit mailing list