[commit] r2500 - in trunk/GME: Common Mga

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Tue Jun 24 12:20:48 CDT 2014


Author: ksmyth
Date: Tue Jun 24 12:20:48 2014
New Revision: 2500

Log:
Check for null Kind in Check. Pass better error messages (SetErrorInfo)

Modified:
   trunk/GME/Common/CommonError.cpp
   trunk/GME/Common/CommonError.h
   trunk/GME/Mga/MgaCheck.cpp
   trunk/GME/Mga/MgaLibOps.cpp
   trunk/GME/Mga/MgaProject.cpp

Modified: trunk/GME/Common/CommonError.cpp
==============================================================================
--- trunk/GME/Common/CommonError.cpp	Thu Jun 19 09:43:52 2014	(r2499)
+++ trunk/GME/Common/CommonError.cpp	Tue Jun 24 12:20:48 2014	(r2500)
@@ -124,6 +124,19 @@
 	}
 }
 
+void throw_last_com_error(HRESULT hr)
+{
+	_bstr_t err;
+	if (GetErrorInfo(err.GetAddress()))
+	{
+		throw_com_error(hr, static_cast<const wchar_t*>(err));
+	}
+	else
+	{
+		throw hresult_exception(hr);
+	}
+}
+
 void SetErrorInfo(LPCOLESTR desc)
 {
 	ASSERT( desc != NULL );

Modified: trunk/GME/Common/CommonError.h
==============================================================================
--- trunk/GME/Common/CommonError.h	Thu Jun 19 09:43:52 2014	(r2499)
+++ trunk/GME/Common/CommonError.h	Tue Jun 24 12:20:48 2014	(r2500)
@@ -136,6 +136,7 @@
 
 
 void throw_com_error(HRESULT hr, LPCOLESTR desc);
+void throw_last_com_error(HRESULT hr);
 void SetErrorInfo(LPCOLESTR desc) NOTHROW;
 void SetErrorInfo(HRESULT hr, LPOLESTR desc2 = NULL) NOTHROW;
 bool GetErrorInfo(BSTR *p) NOTHROW;

Modified: trunk/GME/Mga/MgaCheck.cpp
==============================================================================
--- trunk/GME/Mga/MgaCheck.cpp	Thu Jun 19 09:43:52 2014	(r2499)
+++ trunk/GME/Mga/MgaCheck.cpp	Tue Jun 24 12:20:48 2014	(r2500)
@@ -133,12 +133,15 @@
 
 HRESULT FCO::CheckTree() {
 	COMTRY {
-		COMTHROW(Check());
+		HRESULT hr = Check();
+		if (FAILED(hr))
+			return hr;
 		objtype_enum typ;
 		COMTHROW(get_ObjType(&typ));
 		if(typ == OBJTYPE_FOLDER) {
 				ITERATE_THROUGH(self[ATTRID_FCOPARENT+ATTRID_COLLECTION]) {
-					COMTHROW(ObjForCore(ITER)->CheckTree());
+					if (FAILED(hr = ObjForCore(ITER)->CheckTree()))
+						return hr;
 				}
 		}
 		else {
@@ -194,7 +197,13 @@
 		if(typ == OBJTYPE_FOLDER) {
 			CComPtr<IMgaMetaFolder> parentmf, metaf;
 			COMTHROW(get_MetaFolder(&metaf));
-			if(!parent) {												// root folder
+			if (!metaf) {
+				_bstr_t name;
+				this->get_Name(name.GetAddress());
+				_bstr_t err = L"'";
+				err += parent->Name + "' contains child '" + name + L"' with no assigned kind";
+				throw_com_error(E_MGA_META_VIOLATION, err);
+			} else if(!parent) {												// root folder
 				CComPtr<IMgaMetaProject> mp;
 				COMTHROW(mgaproject->get_RootMeta(&mp));
 				CComPtr<IMgaMetaFolder> mf;
@@ -264,7 +273,13 @@
 			COMTHROW(get_MetaRole( &metarole));
 		
 	
-			if(parenttyp == OBJTYPE_MODEL) {
+			if (meta == NULL) {
+				_bstr_t name;
+				this->get_Name(name.GetAddress());
+				_bstr_t err = L"'";
+				err += parent->Name + "' contains child '" + name + L"' with no assigned kind";
+				throw_com_error(E_MGA_META_VIOLATION, err);
+			} else if(parenttyp == OBJTYPE_MODEL) {
 				if(!metarole)  COMTHROW(E_MGA_NO_ROLE);
 				CComPtr<IMgaMetaModel> parentmeta1;
 				CComPtr<IMgaMetaFCO> parentmeta2;

Modified: trunk/GME/Mga/MgaLibOps.cpp
==============================================================================
--- trunk/GME/Mga/MgaLibOps.cpp	Thu Jun 19 09:43:52 2014	(r2499)
+++ trunk/GME/Mga/MgaLibOps.cpp	Tue Jun 24 12:20:48 2014	(r2500)
@@ -464,9 +464,9 @@
 
 		try 
 		{
-			COMTHROW(p->OpenEx( upgraded?connstr_upgraded:connstr, paradigmname, paradigmGUID));
+			p->__OpenEx( _bstr_t(upgraded?connstr_upgraded:connstr), _bstr_t(paradigmname), _variant_t(paradigmGUID));
 
-			COMTHROW(p->BeginTransaction( NULL, TRANSACTION_READ_ONLY));
+			p->__BeginTransaction( NULL, TRANSACTION_READ_ONLY);
 
 			CComPtr<IMgaFolder> libroot;
 			COMTHROW(p->get_RootFolder(&libroot));
@@ -509,6 +509,15 @@
 
 			fixup.fixPointers();
 		}	
+		catch(_com_error&)
+		{
+			CComBSTR msg( "Exception while loading external library ");
+			COMTHROW(msg.Append( connstr));
+			COMTHROW(msg.Append( " ."));
+			reporter.show( msg);
+
+			throw;
+		}
 		catch(...)
 		{
 			CComBSTR msg( "Exception while loading external library ");

Modified: trunk/GME/Mga/MgaProject.cpp
==============================================================================
--- trunk/GME/Mga/MgaProject.cpp	Thu Jun 19 09:43:52 2014	(r2499)
+++ trunk/GME/Mga/MgaProject.cpp	Tue Jun 24 12:20:48 2014	(r2500)
@@ -343,14 +343,23 @@
 				try {
 					CComPtr<IMgaFolder> rf;
 					COMTHROW(get_RootFolder(&rf));
-					COMTHROW(ObjFor(rf)->CheckTree());
+					HRESULT hr = ObjFor(rf)->CheckTree();
+					if (FAILED(hr))
+					{
+						throw_last_com_error(hr);
+					}
 					rf = 0;
 					COMTHROW(CommitTransaction());
 				} catch(hresult_exception &e) {
 					lm->Flush();
 					AbortTransaction();
 					throw e;
+				} catch(_com_error&) {
+					lm->Flush();
+					AbortTransaction();
+					throw;
 				}
+
 				guidchanged = true;
 			}
 			if(s != soldname || guidchanged) {
@@ -1268,14 +1277,6 @@
 				autoaddoncreate_progid = *i;
 				COMTHROW(CreateMgaComponent(addon, *i)); // Was: COMTHROW( addon.CoCreateInstance(*i) );
 				ASSERT( addon != NULL );
-				CComQIPtr<IGMEVersionInfo> vv = addon;
-				if (vv)
-				{
-					GMEInterfaceVersion_enum v;
-					COMTHROW(vv->get_version(&v));
-					if (v != GMEInterfaceVersion_Current)
-						HR_THROW(E_MGA_COMPONENT_ERROR);
-				}
 
 				COMTHROW( addon->Initialize(this));
 				autocomps.push_front(addon.Detach());


More information about the gme-commit mailing list