[commit] r1407 - trunk/GME/Mga

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Sun Jul 17 18:16:23 CDT 2011


Author: ksmyth
Date: Sun Jul 17 18:16:23 2011
New Revision: 1407

Log:
New preference flag to speed up Mga

Modified:
   trunk/GME/Mga/MgaAttribute.cpp
   trunk/GME/Mga/MgaConnection.cpp
   trunk/GME/Mga/MgaFCO.cpp
   trunk/GME/Mga/MgaTrukk.h

Modified: trunk/GME/Mga/MgaAttribute.cpp
==============================================================================
--- trunk/GME/Mga/MgaAttribute.cpp	Sun Jul 17 18:12:11 2011	(r1406)
+++ trunk/GME/Mga/MgaAttribute.cpp	Sun Jul 17 18:16:23 2011	(r1407)
@@ -933,7 +933,7 @@
 }
 
 STDMETHODIMP CMgaPart::SetGmeAttrs(BSTR icon,long x,long y) { 
-		COMTRY_IN_TRANSACTION {
+	COMTRY_IN_TRANSACTION_MAYBE {
 			fco->CheckWrite();
 			CComBSTR vval;
 			if(icon != NULL) COMTHROW(put_RegistryValue(CComBSTR(L"Icon"), icon));
@@ -943,7 +943,7 @@
 				CComBSTR bb(bbc);
 				COMTHROW(put_RegistryValue(CComBSTR(L"Position"), bb));
 			}
-		} COMCATCH_IN_TRANSACTION(;)
+	} COMCATCH_IN_TRANSACTION_MAYBE(;)
 };
 
 

Modified: trunk/GME/Mga/MgaConnection.cpp
==============================================================================
--- trunk/GME/Mga/MgaConnection.cpp	Sun Jul 17 18:12:11 2011	(r1406)
+++ trunk/GME/Mga/MgaConnection.cpp	Sun Jul 17 18:16:23 2011	(r1407)
@@ -56,7 +56,7 @@
 
 
 HRESULT FCO::put_NamedRole(BSTR rolename,  IMgaFCOs *refs, IMgaFCO *endfco) {
-		COMTRY_IN_TRANSACTION {
+	COMTRY_IN_TRANSACTION_MAYBE {
 			CheckWrite();
 			{
 				booltempflag fl(mgaproject->checkofftemporary);
@@ -76,7 +76,7 @@
 				CComPtr<IMgaConnPoint> tt;
 				COMTHROW(AddConnPoint(rolename, 1, endfco, refs, &tt));
 			}
-		} COMCATCH_IN_TRANSACTION(;)
+	} COMCATCH_IN_TRANSACTION_MAYBE(;)
 }	
 
 HRESULT FCO::CreateSimpleConn( IMgaMetaRole *metar,  IMgaFCO *src,  IMgaFCO *dst, 

Modified: trunk/GME/Mga/MgaFCO.cpp
==============================================================================
--- trunk/GME/Mga/MgaFCO.cpp	Sun Jul 17 18:12:11 2011	(r1406)
+++ trunk/GME/Mga/MgaFCO.cpp	Sun Jul 17 18:16:23 2011	(r1407)
@@ -202,6 +202,7 @@
 				*pVal = CComQIPtr<IMgaMetaRole>(mgaproject->FindMetaRef(role)).Detach();
 				if(!(*pVal)) COMTHROW(E_MGA_META_INCOMPATIBILITY);
 			}
+			// FIXME: need to return an E_ here
 
 		} COMCATCH(;);
 }
@@ -435,15 +436,15 @@
 }
 
 HRESULT FCO::put_Name(BSTR newVal)    { 
-	COMTRY_IN_TRANSACTION {
-		CheckWrite();
+	COMTRY_IN_TRANSACTION_MAYBE {
+	CheckWrite();
 		CHECK_INPAR(newVal);  
 		if(self[ATTRID_PERMISSIONS] & LIBROOT_FLAG) COMTHROW(E_MGA_LIBOBJECT);
 		if(CComBSTR(self[ATTRID_NAME]) != newVal) {
 			put_NameTask(CComBSTR(self[ATTRID_NAME]), newVal).DoWithDeriveds(self);;
 		}
 	}
-	COMCATCH_IN_TRANSACTION(;);	
+	COMCATCH_IN_TRANSACTION_MAYBE(;);	
 };
 
 void giveme( CMgaProject *mgaproject, CoreObj par, CoreObj cur, CComBSTR cur_kind, int *relpos)

Modified: trunk/GME/Mga/MgaTrukk.h
==============================================================================
--- trunk/GME/Mga/MgaTrukk.h	Sun Jul 17 18:12:11 2011	(r1406)
+++ trunk/GME/Mga/MgaTrukk.h	Sun Jul 17 18:16:23 2011	(r1407)
@@ -97,14 +97,15 @@
 // ----------------------------------------
 // STL compatible wrapped for CComBSTR
 // ----------------------------------------
-class CComBSTRNoAt : public CComBSTR {
+/*class CComBSTRNoAt : public CComBSTR {
 public:
 	CComBSTRNoAt() {;};
 	CComBSTRNoAt(const CComBSTR &sss) : CComBSTR(sss) {;}
 	CComBSTRNoAt* const operator&() {
 		return this;
 	}
-};
+};*/
+typedef CComBSTR CComBSTRNoAt;	
 
 
 // ----------------------------------------
@@ -297,6 +298,37 @@
 	} \
 	return ttt.Commit(); }
 
+#define MGAPREF_NO_NESTED_TX 0x00000080
+
+#define COMTRY_IN_TRANSACTION_MAYBE \
+long prefmask; \
+HRESULT hr = this->mgaproject->get_Preferences(&prefmask); \
+if (FAILED(hr)) \
+	return hr; \
+Transaction ttt; \
+if (!(prefmask & MGAPREF_NO_NESTED_TX)) { \
+  HRESULT hr = ttt.Begin(mgaproject); \
+  if (hr != S_OK) return hr; \
+} \
+try
+
+#define COMCATCH_IN_TRANSACTION_MAYBE( CLEANUP )  \
+catch(hresult_exception &e) \
+{ \
+	ASSERT( FAILED(e.hr) ); \
+	{ \
+		if(!(prefmask & MGAPREF_NO_NESTED_TX) && ((hr = ttt.Abort()) != S_OK)) return hr; \
+		CLEANUP; \
+	} \
+	MgaSetErrorInfo(e.hr); \
+	return e.hr; \
+} \
+if (!(prefmask & MGAPREF_NO_NESTED_TX)) \
+	return ttt.Commit(); \
+else \
+	return S_OK;
+
+
 #define MODIFIED	{ if(mgaproject->opened < 1000) mgaproject->opened++; }
  
 #undef COMCATCH


More information about the gme-commit mailing list