[commit] r2082 - in trunk/GME: Common Gme Mga
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Thu Oct 18 10:30:25 CDT 2012
Author: ksmyth
Date: Thu Oct 18 10:30:25 2012
New Revision: 2082
Log:
Fix crash on paste causing constraint violation. Change SetErrorInfo to also set Mga HRESULTs. Fixes crashrpt 9b8c332f-6cee-47c8-82bd-f51224b80694 among others
Modified:
trunk/GME/Common/CommonError.cpp
trunk/GME/Gme/GMEView.cpp
trunk/GME/Mga/Mga.cpp
trunk/GME/Mga/MgaErr.c
trunk/GME/Mga/MgaTrukk.h
Modified: trunk/GME/Common/CommonError.cpp
==============================================================================
--- trunk/GME/Common/CommonError.cpp Thu Oct 18 10:30:09 2012 (r2081)
+++ trunk/GME/Common/CommonError.cpp Thu Oct 18 10:30:25 2012 (r2082)
@@ -145,6 +145,38 @@
}
}
+
+struct errtab {
+ long code;
+ LPOLESTR descr;
+};
+
+#include "..\Mga\MgaErr.c"
+
+#define MGAERRCODEBASE 0x87650000
+#define MGAERRCODESPAN 0x1000
+
+LPCOLESTR MgaGetErrorInfo(HRESULT hr) {
+ if(hr >= MGAERRCODEBASE && hr < MGAERRCODEBASE + MGAERRCODESPAN) {
+ for(struct errtab const *hh = MgaErrTab; hh->code != 0; hh++) {
+ if(hh->code == hr) {
+ return hh->descr;
+ }
+ }
+ }
+ return NULL;
+}
+
+bool MgaSetErrorInfo(HRESULT hr) {
+ LPCOLESTR mgaError = MgaGetErrorInfo(hr);
+ if (mgaError)
+ {
+ SetErrorInfo(mgaError);
+ return true;
+ }
+ return false;
+}
+
void SetErrorInfo(HRESULT hr, LPOLESTR desc2)
{
ASSERT( sizeof(common_descs)/sizeof(LPOLESTR) == (E_COMMON_LAST-E_COMMON_FIRST+1) );
@@ -162,6 +194,10 @@
{
if( desc != NULL )
SetErrorInfo(desc);
+ else if (hr >= MGAERRCODEBASE && hr < MGAERRCODEBASE + MGAERRCODESPAN)
+ {
+ MgaSetErrorInfo(hr);
+ }
}
else
{
@@ -209,6 +245,14 @@
SysFreeString(*p);
*p = SysAllocString(desc);
}
+ else if (hr >= MGAERRCODEBASE && hr < MGAERRCODEBASE + MGAERRCODESPAN)
+ {
+ LPCOLESTR mgaError = MgaGetErrorInfo(hr);
+ if (mgaError)
+ *p = SysAllocString(mgaError);
+ else
+ GetErrorInfo(E_FAIL, p);
+ }
else
{
LPWSTR errorText = NULL;
@@ -219,7 +263,10 @@
*p = SysAllocString(errorText);
LocalFree(errorText);
} else {
- GetErrorInfo(p);
+ if (!GetErrorInfo(p))
+ {
+ GetErrorInfo(E_FAIL, p);
+ }
}
}
}
Modified: trunk/GME/Gme/GMEView.cpp
==============================================================================
--- trunk/GME/Gme/GMEView.cpp Thu Oct 18 10:30:09 2012 (r2081)
+++ trunk/GME/Gme/GMEView.cpp Thu Oct 18 10:30:25 2012 (r2082)
@@ -3846,6 +3846,8 @@
}
catch (hresult_exception& e) {
AbortTransaction(e.hr);
+ if (e.hr == E_MGA_CONSTRAINT_VIOLATION)
+ return false;
_bstr_t err;
GetErrorInfo(e.hr, err.GetAddress());
AfxMessageBox((std::wstring(L"Unable to insert objects: ") + static_cast<const wchar_t*>(err)).c_str(), MB_ICONSTOP | MB_OK); // in most cases there was an error msg already...
@@ -3903,6 +3905,8 @@
_bstr_t err;
GetErrorInfo(e.hr, err.GetAddress());
AbortTransaction(e.hr);
+ if (e.hr == E_MGA_CONSTRAINT_VIOLATION)
+ return false;
AfxMessageBox((std::wstring(L"Unable to insert objects: ") + static_cast<const wchar_t*>(err)).c_str(), MB_ICONSTOP | MB_OK);
CGMEEventLogger::LogGMEEvent(_T(" Unable to insert objects.\r\n"));
newObjectIDs.RemoveAll();
Modified: trunk/GME/Mga/Mga.cpp
==============================================================================
--- trunk/GME/Mga/Mga.cpp Thu Oct 18 10:30:09 2012 (r2081)
+++ trunk/GME/Mga/Mga.cpp Thu Oct 18 10:30:25 2012 (r2082)
@@ -143,30 +143,6 @@
#include "MgaO.h"
-struct errtab {
- long code;
- LPOLESTR descr;
-};
-
-#include "MgaErr.c"
-
-#define MGAERRCODEBASE 0x87650000
-#define MGAERRCODESPAN 0x1000
-
-void MgaSetErrorInfo(HRESULT hr) {
- if(hr >= MGAERRCODEBASE && hr < MGAERRCODEBASE + MGAERRCODESPAN) {
- for(struct errtab const *hh = MgaErrTab; hh->code != 0; hh++) {
- if(hh->code == hr) {
- SetErrorInfo(hh->descr);
- return;
- }
- }
- return;
- }
-// Do not set errorinfo if it is returned by other modules, it is their responsibility
-// SetErrorInfo(hr);
-}
-
#ifdef DEBUG
HRESULT CheckErrTab(void) {
Modified: trunk/GME/Mga/MgaErr.c
==============================================================================
--- trunk/GME/Mga/MgaErr.c Thu Oct 18 10:30:09 2012 (r2081)
+++ trunk/GME/Mga/MgaErr.c Thu Oct 18 10:30:25 2012 (r2082)
@@ -6,6 +6,74 @@
// to E:\GMESRC\GME\Mga\MgaErr.c
// using script E:\GMESRC\GME\Mga\scripts\createerrtab.py
+
+namespace {
+
+typedef enum mgaerrors
+ { E_MGA_NOT_IMPLEMENTED = 0x87650000,
+ E_MGA_NOT_SUPPORTED = 0x87650001,
+ E_MGA_MODULE_INCOMPATIBILITY = 0x87650010,
+ E_MGA_PARADIGM_NOTREG = 0x87650011,
+ E_MGA_PARADIGM_INVALID = 0x87650012,
+ E_MGA_COMPONENT_ERROR = 0x87650013,
+ E_MGA_DATA_INCONSISTENCY = 0x87650021,
+ E_MGA_META_INCOMPATIBILITY = 0x87650022,
+ E_MGA_PROJECT_OPEN = 0x87650031,
+ E_MGA_PROJECT_NOT_OPEN = 0x87650032,
+ E_MGA_READ_ONLY_ACCESS = 0x87650033,
+ E_MGA_NOT_IN_TERRITORY = 0x87650034,
+ E_MGA_NOT_IN_TRANSACTION = 0x87650035,
+ E_MGA_ALREADY_IN_TRANSACTION = 0x87650036,
+ E_MGA_MUST_ABORT = 0x87650037,
+ E_MGA_TARGET_DESTROYED = 0x87650038,
+ E_MGA_FOREIGN_PROJECT = 0x87650041,
+ E_MGA_FOREIGN_OBJECT = 0x87650042,
+ E_MGA_OBJECT_DELETED = 0x87650051,
+ E_MGA_OBJECT_ZOMBIE = 0x87650052,
+ E_MGA_ZOMBIE_NOPROJECT = 0x87650053,
+ E_MGA_ZOMBIE_CLOSED_PROJECT = 0x87650054,
+ E_MGA_INVALID_ARG = 0x87650060,
+ E_MGA_ARG_RANGE = 0x87650061,
+ E_MGA_INPTR_NULL = 0x87650062,
+ E_MGA_OUTPTR_NONEMPTY = 0x87650063,
+ E_MGA_OUTPTR_NULL = 0x87650064,
+ E_MGA_NAME_NOT_FOUND = 0x87650070,
+ E_MGA_NAME_DUPLICATE = 0x87650071,
+ E_MGA_META_VIOLATION = 0x87650072,
+ E_MGA_NOT_CHANGEABLE = 0x87650073,
+ E_MGA_OP_REFUSED = 0x87650074,
+ E_MGA_LIBOBJECT = 0x87650075,
+ E_META_INVALIDATTR = 0x87650080,
+ E_META_INVALIDASPECT = 0x87650081,
+ E_MGA_ACCESS_TYPE = 0x87650082,
+ E_MGA_BAD_ENUMVALUE = 0x87650083,
+ E_MGA_REFPORTS_USED = 0x87650131,
+ E_MGA_VIRTUAL_NODE = 0x87650136,
+ E_MGA_BAD_POSITIONVALUE = 0x87650137,
+ E_MGA_ROOTFCO = 0x87650138,
+ E_MGA_NOT_ROOTOBJECT = 0x87650138,
+ E_MGA_BAD_COLLENGTH = 0x87650140,
+ E_MGA_INVALID_ROLE = 0x87650142,
+ E_MGA_BAD_ID = 0x87650143,
+ E_MGA_NOT_DERIVABLE = 0x87650144,
+ E_MGA_OBJECT_NOT_MEMBER = 0x87650145,
+ E_MGA_NOT_CONNECTIBLE = 0x87650146,
+ E_MGA_NO_ROLE = 0x87650147,
+ E_MGA_CONNROLE_USED = 0x87650148,
+ E_MGA_NOT_DERIVED = 0x87650149,
+ E_MGA_NOT_INSTANCE = 0x87650150,
+ E_MGA_INSTANCE = 0x87650151,
+ E_MGA_REFERENCE_EXPECTED = 0x87650152,
+ E_MGA_FILTERFORMAT = 0x87650153,
+ E_MGA_GEN_OUT_OF_SPACE = 0x87650154,
+ E_MGA_INVALID_TARGET = 0x87650155,
+ E_MGA_LONG_DERIVCHAIN = 0x87650156,
+ E_MGA_LIB_DIFF = 0x87650157,
+ E_MGA_BAD_MASKVALUE = 0x87650170,
+ E_MGA_CONSTRAINT_VIOLATION = 0x87657fff,
+ E_MGA_ERRCODE_ERROR = 0x87658000
+ } mgaerrors;
+
const struct errtab MgaErrTab[]= {
{E_MGA_NOT_IMPLEMENTED, L"This method is not yet implemented"},
{E_MGA_NOT_SUPPORTED, L"This mode of operation is not supported"},
@@ -70,3 +138,4 @@
{E_MGA_CONSTRAINT_VIOLATION, L"Constraint violation"},
{E_MGA_ERRCODE_ERROR, L"Errcode out of errcode range"},
{0}};
+}
Modified: trunk/GME/Mga/MgaTrukk.h
==============================================================================
--- trunk/GME/Mga/MgaTrukk.h Thu Oct 18 10:30:09 2012 (r2081)
+++ trunk/GME/Mga/MgaTrukk.h Thu Oct 18 10:30:25 2012 (r2082)
@@ -286,7 +286,7 @@
if(hr != S_OK) return hr; \
try
-void MgaSetErrorInfo(HRESULT hr);
+bool MgaSetErrorInfo(HRESULT hr);
#define COMCATCH_IN_TRANSACTION( CLEANUP ) \
catch(hresult_exception &e) \
More information about the gme-commit
mailing list