[commit] r2665 - in trunk/GME: Mga Parser

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Mon Feb 27 16:42:26 CST 2017


Author: ksmyth
Date: Mon Feb 27 16:42:25 2017
New Revision: 2665

Log:
Fix bug where derived FCOs may have RelID 0x08000000 after xme import

The issue is that derived FCOs are created all at once with DeriveRootObject,
but, when parsing a non-primary derived, the archetype may not have its RelID
set yet due to a pass_exception (e.g. missing reference target).

The fix is to set the RelID of non-primary deriveds when they are being parsed.

Modified:
   trunk/GME/Mga/MgaFCO.cpp
   trunk/GME/Parser/MgaParser.cpp

Modified: trunk/GME/Mga/MgaFCO.cpp
==============================================================================
--- trunk/GME/Mga/MgaFCO.cpp	Thu Feb 16 08:57:54 2017	(r2664)
+++ trunk/GME/Mga/MgaFCO.cpp	Mon Feb 27 16:42:25 2017	(r2665)
@@ -191,7 +191,8 @@
 HRESULT FCO::put_RelID(long newVal) {
 	COMTRY_IN_TRANSACTION {
 		CheckWrite();
-		if(newVal <= 0 || newVal >= RELIDSPACE) COMTHROW(E_MGA_ARG_RANGE);
+		if (newVal <= 0)
+			COMTHROW(E_MGA_ARG_RANGE);
 		self[ATTRID_RELID] = newVal;
 	} COMCATCH_IN_TRANSACTION(;);
 }

Modified: trunk/GME/Parser/MgaParser.cpp
==============================================================================
--- trunk/GME/Parser/MgaParser.cpp	Thu Feb 16 08:57:54 2017	(r2664)
+++ trunk/GME/Parser/MgaParser.cpp	Mon Feb 27 16:42:25 2017	(r2665)
@@ -1207,6 +1207,8 @@
 			else
 			{
 				COMTHROW( prev->get_ChildDerivedFrom(derivedfrom, PutOut(model)) );
+				// models cannot throw pass_exception (except for subtype inheritance), so this isn't needed
+				// fco->RelID = (~RELID_BASE_MAX &fco->RelID) | (RELID_BASE_MAX & derivedfrom->RelID);
 			}
 		}
 		else
@@ -1283,6 +1285,8 @@
 			else
 			{
 				COMTHROW( prev->get_ChildDerivedFrom(derivedfrom, PutOut(atom)) );
+				// models and atoms can't throw pass_exception (except for subtype inheritance), so this isn't needed
+				// fco->RelID = (~RELID_BASE_MAX &fco->RelID) | (RELID_BASE_MAX & derivedfrom->RelID);
 			}
 		}
 		else
@@ -1435,6 +1439,12 @@
 			else
 			{
 				COMTHROW( prev->get_ChildDerivedFrom(derivedfrom, PutOut(conn)) );
+				// If conn's parent (or primary derived ancestor) was being parsed before derivedfrom,
+				// then derivedfrom won't have had the correct RelID when Derive{Root,Child}Object was called.
+				// This can happen when parsing derivedfrom throws pass_exception.
+				// Set it now, retaining the high bits that indicate non-primary derivation.
+				// (We know derivedfrom is parsed at this point, since ResolveDerivation would throw otherwise)
+				conn->RelID = (~RELID_BASE_MAX &conn->RelID) | (RELID_BASE_MAX & derivedfrom->RelID);
 			}
 		}
 		else
@@ -1623,6 +1633,7 @@
 			else
 			{
 				COMTHROW( prev->get_ChildDerivedFrom(derivedfrom, PutOut(fco)) );
+				fco->RelID = (~RELID_BASE_MAX &fco->RelID) | (RELID_BASE_MAX & derivedfrom->RelID);
 			}
 		}
 		else
@@ -1737,9 +1748,8 @@
 			}
 			else
 			{
-				preparerelid(attributes);
 				COMTHROW( prev->get_ChildDerivedFrom(derivedfrom, PutOut(fco)) );
-				assignrelid(fco);
+				fco->RelID = (~RELID_BASE_MAX &fco->RelID) | (RELID_BASE_MAX & derivedfrom->RelID);
 			}
 		}
 		else


More information about the gme-commit mailing list