[commit] r1128 - in trunk/GME: Common MgaUtil
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Jan 12 16:49:24 CST 2011
Author: ksmyth
Date: Wed Jan 12 16:49:24 2011
New Revision: 1128
Log:
Fix problem where component returns with an error and no open transaction, GetErrorInfo is called after AbortTransaction, which results in "Operation needs to execute within transaction". Properly query component for ISupportErrorInfo (probably just .NET components) otherwise use GME error lookup and FormatMessage for error
Modified:
trunk/GME/Common/CommonError.h
trunk/GME/Common/CommonSmart.cpp
trunk/GME/MgaUtil/MgaLauncher.cpp
Modified: trunk/GME/Common/CommonError.h
==============================================================================
--- trunk/GME/Common/CommonError.h Wed Jan 12 12:53:55 2011 (r1127)
+++ trunk/GME/Common/CommonError.h Wed Jan 12 16:49:24 2011 (r1128)
@@ -108,7 +108,7 @@
void SetErrorInfo(LPOLESTR desc) NOTHROW;
void SetErrorInfo(HRESULT hr, LPOLESTR desc2 = NULL) NOTHROW;
-void GetErrorInfo(BSTR *p) NOTHROW;
+bool GetErrorInfo(BSTR *p) NOTHROW;
void GetErrorInfo(HRESULT hr, BSTR *p) NOTHROW;
// One or more arguments are invalid
Modified: trunk/GME/Common/CommonSmart.cpp
==============================================================================
--- trunk/GME/Common/CommonSmart.cpp Wed Jan 12 12:53:55 2011 (r1127)
+++ trunk/GME/Common/CommonSmart.cpp Wed Jan 12 16:49:24 2011 (r1128)
@@ -29,8 +29,7 @@
if( len <= 0 )
return;
- UINT acp = GetACP();
- int blen = MultiByteToWideChar(acp, 0, p, len, NULL, 0);
+ int blen = MultiByteToWideChar(CP_UTF8, 0, p, len, NULL, 0);
if( blen <= 0 )
HR_THROW(E_CONVERSION);
@@ -39,7 +38,7 @@
if( *b == NULL )
HR_THROW(E_OUTOFMEMORY);
- int tlen = MultiByteToWideChar(acp, 0, p, len, *b, blen);
+ int tlen = MultiByteToWideChar(CP_UTF8, 0, p, len, *b, blen);
if( tlen <= 0 )
HR_THROW(E_CONVERSION);
@@ -56,9 +55,7 @@
if( olelen == 0 )
return 0;
- UINT acp = GetACP();
-
- int charlen = WideCharToMultiByte(acp, 0, p, olelen,
+ int charlen = WideCharToMultiByte(CP_UTF8, 0, p, olelen,
NULL, 0, NULL, NULL);
// zero if failed
@@ -75,9 +72,7 @@
if( charlen <= 0 )
return;
- UINT acp = GetACP();
-
- int len = WideCharToMultiByte(acp, 0, p, olelen,
+ int len = WideCharToMultiByte(CP_UTF8, 0, p, olelen,
s, charlen, NULL, NULL);
// zero if failed
Modified: trunk/GME/MgaUtil/MgaLauncher.cpp
==============================================================================
--- trunk/GME/MgaUtil/MgaLauncher.cpp Wed Jan 12 12:53:55 2011 (r1127)
+++ trunk/GME/MgaUtil/MgaLauncher.cpp Wed Jan 12 16:49:24 2011 (r1128)
@@ -643,6 +643,7 @@
}
static int __stdcall nopExceptionFilter(unsigned int code, struct _EXCEPTION_POINTERS* ep) {
+ // FIXME: if (ep->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)
return EXCEPTION_EXECUTE_HANDLER;
}
@@ -764,35 +765,46 @@
if(AfxMessageBox(aa, MB_YESNO) !=IDYES) return S_OK;
}
}
- {
- if(parameter.vt != VT_BOOL || parameter.boolVal != VARIANT_TRUE) {
- try {
- COMTHROW(component->Initialize(project));
- CComQIPtr<IMgaComponentEx> compex = component;
- 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.");
+ if(parameter.vt != VT_BOOL || parameter.boolVal != VARIANT_TRUE) {
+ CComQIPtr<IMgaComponentEx> compex = component;
+ if (compex) {
+ CComQIPtr<ISupportErrorInfo> supportErrorInfo = component;
+ HRESULT hr = component->Initialize(project);
+ // Need to catch SEH exceptions (especially for Win7 x64: see GME-318)
+ if (SUCCEEDED(hr) && !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 {
+ if (!SUCCEEDED(hr)) {
+ BSTR desc = NULL;
+ if (supportErrorInfo && GetErrorInfo(&desc)) {
+ CString msg;
+ CopyTo(desc, msg);
+ msg = "Component error: " + msg;
+ AfxMessageBox(msg, MB_OK | MB_ICONSTOP);
+ SysFreeString(desc);
} else {
- COMTHROW(hr);
+ DisplayError("Component error", hr);
}
+ project->AbortTransaction();
}
- else {
- CComPtr<IMgaTerritory> terr;
- COMTHROW(project->CreateTerritory(NULL, &terr));
- COMTHROW(project->BeginTransaction(terr));
- try {
- COMTHROW( component->Invoke(project, selectedobjs, param) );
- COMTHROW(project->CommitTransaction());
- }
- catch(...)
- {
- project->AbortTransaction();
- throw;
- }
+ }
+ } else {
+ try {
+ COMTHROW(component->Initialize(project));
+ CComPtr<IMgaTerritory> terr;
+ COMTHROW(project->CreateTerritory(NULL, &terr));
+ COMTHROW(project->BeginTransaction(terr));
+ try {
+ COMTHROW( component->Invoke(project, selectedobjs, param) );
+ COMTHROW(project->CommitTransaction());
+ }
+ catch(...)
+ {
+ project->AbortTransaction();
+ throw;
}
}
catch(hresult_exception &e) {
@@ -807,35 +819,38 @@
"Please save your work and restart GME.");
}
}
- else { // running unprotected
- try {
- COMTHROW(component->Initialize(project));
- CComQIPtr<IMgaComponentEx> compex = component;
- if(compex) {
- COMTHROW(compex->InvokeEx(project, focusobj, CComQIPtr<IMgaFCOs>(selectedobjs), param));
+ }
+ else { // running unprotected
+ try {
+ COMTHROW(component->Initialize(project));
+ CComQIPtr<IMgaComponentEx> compex = component;
+ if(compex) {
+ COMTHROW(compex->InvokeEx(project, focusobj, CComQIPtr<IMgaFCOs>(selectedobjs), param));
+ }
+ else {
+ CComPtr<IMgaTerritory> terr;
+ COMTHROW(project->CreateTerritory(NULL, &terr));
+ COMTHROW(project->BeginTransaction(terr));
+ try {
+ COMTHROW( component->Invoke(project, selectedobjs, param) );
+ COMTHROW(project->CommitTransaction());
}
- else {
- CComPtr<IMgaTerritory> terr;
- COMTHROW(project->CreateTerritory(NULL, &terr));
- COMTHROW(project->BeginTransaction(terr));
- try {
- COMTHROW( component->Invoke(project, selectedobjs, param) );
- COMTHROW(project->CommitTransaction());
- }
- catch(...)
- {
- project->AbortTransaction();
- throw;
- }
+ catch(...)
+ {
+ project->AbortTransaction();
+ throw;
}
}
- catch(hresult_exception &e) {
- DisplayError("Component error", e.hr);
- }
- }
- }
+ }
+ catch(hresult_exception &e) {
+ DisplayError("Component error", e.hr);
+ }
+ }
}
- } COMCATCH(;);
+// component.Release();
+// CoFreeUnusedLibraries();
+// } COMCATCH(CoFreeUnusedLibraries(););
+ } COMCATCH();
}
// ------ Helper functions
More information about the gme-commit
mailing list