[commit] r2536 - trunk/GME/Parser

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Sep 24 09:55:07 CDT 2014


Author: ksmyth
Date: Wed Sep 24 09:55:07 2014
New Revision: 2536

Log:
MgaParser: dont crash if project is not open

Modified:
   trunk/GME/Parser/MgaParser.cpp

Modified: trunk/GME/Parser/MgaParser.cpp
==============================================================================
--- trunk/GME/Parser/MgaParser.cpp	Wed Sep 24 09:55:04 2014	(r2535)
+++ trunk/GME/Parser/MgaParser.cpp	Wed Sep 24 09:55:07 2014	(r2536)
@@ -24,6 +24,18 @@
 	CHECK_IN(here);
 	m_maintainGuids = false;
 
+	CComObjPtr<IMgaProject> p;
+	HRESULT hr = here->get_Project(PutOut(p));
+	if (FAILED(hr))
+		return hr;
+	if ((p->ProjectStatus & 1) == 0)
+	{
+		clear_GME(m_GME);
+		SetErrorInfo(L"Project is not open");
+
+		return E_MGA_ZOMBIE_NOPROJECT;
+	}
+
 	try
 	{
 		HWND hwndParent = (HWND)hwndParent_;
@@ -34,8 +46,6 @@
 			COMTHROW( progress->StartProgressDialog(hwndParent) );
 		}
 
-		CComObjPtr<IMgaProject> p;
-		COMTHROW( here->get_Project(PutOut(p)) );
 		ASSERT( p != NULL );
 		COMTHROW( p->get_Preferences(&project_prefs_orig) );
 		manual_relid_mode = project_prefs_orig & MGAPREF_MANUAL_RELIDS ? true : false;
@@ -180,6 +190,13 @@
 	CHECK_IN(p);
 	m_maintainGuids = true; //will be set to false if p is NOT empty
 
+	if ((p->ProjectStatus & 1) == 0)
+	{
+		clear_GME(m_GME);
+		SetErrorInfo(L"Project is not open");
+
+		return E_MGA_ZOMBIE_NOPROJECT;
+	}
 	try
 	{
 		HWND hwndParent = (HWND)hwndParent_;
@@ -441,8 +458,12 @@
 
 	if( project != NULL )
 	{
+
 		COMTHROW(project->put_Preferences(project_prefs_orig));
-		COMTHROW(project->AbortTransaction());
+		if (project->ProjectStatus & 8)
+		{
+			COMTHROW(project->AbortTransaction());
+		}
 		COMTHROW(project->Notify(APPEVENT_XML_IMPORT_END));
 	}
 


More information about the gme-commit mailing list