[GME-commit] GMESRC/GME/MgaUtil MgaResolver.cpp,1.13,1.14

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Sat Jun 2 10:35:52 CDT 2007


Update of /project/gme-repository/GMESRC/GME/MgaUtil
In directory escher:/tmp/cvs-serv5686

Modified Files:
	MgaResolver.cpp 
Log Message:
Do not return from the middle of an iteration over a com collection.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: MgaResolver.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MgaResolver.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** MgaResolver.cpp	21 Jul 2006 19:23:30 -0000	1.13
--- MgaResolver.cpp	2 Jun 2007 15:35:49 -0000	1.14
***************
*** 748,792 ****
  					ASSERT(targ_parts!=NULL);
  
  					MGACOLL_ITERATE(IMgaMetaPart, targ_parts) {
  
! 						targ_part_ix = MGACOLL_ITER;
! 						ASSERT(targ_part_ix != NULL);
  
! 						CComBSTR name;
  
! 						VARIANT_BOOL vb_primary;
  
! 						COMTHROW(targ_part_ix->get_IsPrimary(&vb_primary) );
  
! 						if (vb_primary != VARIANT_FALSE) {
  
! 							targ_aspect = NULL;
! 							COMTHROW( targ_part_ix->get_ParentAspect(&targ_aspect) );
! 							ASSERT(targ_aspect != NULL);
! 							COMTHROW( targ_aspect->get_Name(&name) );
! 							
! 							CString cb1((BSTR) name);
! 							CString cb2(aspect);
  
! 							if ((cb2 == "") || (cb2 == cb1 )) {
  
! 								// finally-- success!
  
! 								// ??? PETER: Why do we increase the refcount here ?
! 								COMTHROW( targ_role.CopyTo(p) );
! 								
! 								
  
! 								// map entry
  
! 								this->map_put_RoleByStr(
! 									parent_meta.p,
! 									kind,
! 									objtype,
! 									role,
! 									aspect,
! 									*p);
  
! 								return S_OK;
  							}
  
--- 748,796 ----
  					ASSERT(targ_parts!=NULL);
  
+ 					bool found = false;
  					MGACOLL_ITERATE(IMgaMetaPart, targ_parts) {
  
! 						if( !found) {
! 							targ_part_ix = MGACOLL_ITER;
! 							ASSERT(targ_part_ix != NULL);
  
! 							CComBSTR name;
  
! 							VARIANT_BOOL vb_primary;
  
! 							COMTHROW(targ_part_ix->get_IsPrimary(&vb_primary) );
  
! 							if (vb_primary != VARIANT_FALSE) {
  
! 								targ_aspect = NULL;
! 								COMTHROW( targ_part_ix->get_ParentAspect(&targ_aspect) );
! 								ASSERT(targ_aspect != NULL);
! 								COMTHROW( targ_aspect->get_Name(&name) );
! 								
! 								CString cb1((BSTR) name);
! 								CString cb2(aspect);
  
! 								if ((cb2 == "") || (cb2 == cb1 )) {
  
! 									// finally-- success!
  
! 									// ??? PETER: Why do we increase the refcount here ?
! 									COMTHROW( targ_role.CopyTo(p) );
! 									
! 									
  
! 									// map entry
  
! 									this->map_put_RoleByStr(
! 										parent_meta.p,
! 										kind,
! 										objtype,
! 										role,
! 										aspect,
! 										*p);
  
! 									found = true;  // do not return from the middle of an iteration
! 									//return S_OK; // hopefully p will not change
! 								}
  							}
  
***************
*** 798,802 ****
  					} // eo for()
  					MGACOLL_ITERATE_END;
! 
  				}
  			}
--- 802,806 ----
  					} // eo for()
  					MGACOLL_ITERATE_END;
! 					if( found) return S_OK;
  				}
  			}
***************
*** 888,924 ****
  					ASSERT(targ_parts != NULL);
  
  					MGACOLL_ITERATE(IMgaMetaPart, targ_parts) {
  
! 						targ_part_ix = MGACOLL_ITER;
! 						ASSERT( targ_part_ix != NULL );
  
! 						VARIANT_BOOL vb_primary;
  
! 						COMTHROW(targ_part_ix->get_IsPrimary(&vb_primary) );
  
! 						if (vb_primary != VARIANT_FALSE) {
  
! 							targ_aspect = NULL;
! 							COMTHROW( targ_part_ix->get_ParentAspect(&targ_aspect) );
! 							ASSERT( targ_aspect != NULL);
  
! 							CComBSTR asp_name;
  
! 							COMTHROW( targ_aspect->get_Name(&asp_name) );
  
! 							CString cz1(aspect);
! 							CString cz2(asp_name);
  
! 							if (cz1 == cz2) {
  
! 								COMTHROW( targ_role.CopyTo(p) );
  
! 								// update map
  
! 								this->map_put_RoleByStr(parent_meta.p, 
! 									kind, objtype, role, aspect, *p);
  
! 								return S_OK;
  
  							}
  
--- 892,932 ----
  					ASSERT(targ_parts != NULL);
  
+ 					bool found = false;
  					MGACOLL_ITERATE(IMgaMetaPart, targ_parts) {
  
! 						if( !found) {
! 							targ_part_ix = MGACOLL_ITER;
! 							ASSERT( targ_part_ix != NULL );
  
! 							VARIANT_BOOL vb_primary;
  
! 							COMTHROW(targ_part_ix->get_IsPrimary(&vb_primary) );
  
! 							if (vb_primary != VARIANT_FALSE) {
  
! 								targ_aspect = NULL;
! 								COMTHROW( targ_part_ix->get_ParentAspect(&targ_aspect) );
! 								ASSERT( targ_aspect != NULL);
  
! 								CComBSTR asp_name;
  
! 								COMTHROW( targ_aspect->get_Name(&asp_name) );
  
! 								CString cz1(aspect);
! 								CString cz2(asp_name);
  
! 								if (cz1 == cz2) {
  
! 									COMTHROW( targ_role.CopyTo(p) );
  
! 									// update map
  
! 									this->map_put_RoleByStr(parent_meta.p, 
! 										kind, objtype, role, aspect, *p);
  
! 									found = true;  // do not return from the middle of an iteration
! 									//return S_OK; // hopefully p will not change after this
  
+ 								}
  							}
  
***************
*** 927,930 ****
--- 935,939 ----
  					}
  					MGACOLL_ITERATE_END;
+ 					if( found) return S_OK;
  
  				} // eo if (count == 1)



More information about the GME-commit mailing list