[commit] r1477 - trunk/GME/Mga

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Tue Aug 23 16:50:38 CDT 2011


Author: ksmyth
Date: Tue Aug 23 16:50:38 2011
New Revision: 1477

Log:
Fix crash after MgaProject::Close then MgaTerritory::FinalRelease

Modified:
   trunk/GME/Mga/MgaTerritory.cpp

Modified: trunk/GME/Mga/MgaTerritory.cpp
==============================================================================
--- trunk/GME/Mga/MgaTerritory.cpp	Tue Aug 23 16:50:37 2011	(r1476)
+++ trunk/GME/Mga/MgaTerritory.cpp	Tue Aug 23 16:50:38 2011	(r1477)
@@ -86,7 +86,9 @@
 	COMTRY {
 		if (!coreterr) 
 			return E_MGA_TARGET_DESTROYED;
-		COMTHROW(Flush());
+		// n.b. Flush fails if the project has been closed, but if we're being destructed, we must still remove
+		// this from allterrs, or MgaProject::~MgaProject will crash (as allterrs does not count references)
+		HRESULT hr = Flush();
 		CMgaProject::tercoll::iterator i = mgaproject->allterrs.begin(), end = mgaproject->allterrs.end();
 		for(;i != end; ++i) {
 			if(*i == this) {
@@ -94,11 +96,12 @@
 				coreterr = NULL;   // release CoreTerritory object
 				handler = NULL;	// release sink
 				rwhandler = NULL;	// release sink
-				return S_OK;
+				COMRETURN(hr);
 			}
 			
 		}
 		ASSERT(false);	// not found among project territories
+		COMRETURN(hr);
 	} COMCATCH(;)
 }
 


More information about the gme-commit mailing list