[GME-commit] GMESRC/GME/Parser MgaDumper.cpp,1.21,1.22
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Thu Jan 20 11:25:03 CST 2005
Update of /var/lib/gme/GMESRC/GME/Parser
In directory braindrain:/tmp/cvs-serv13254
Modified Files:
MgaDumper.cpp
Log Message:
MgaDumper::removeInnerObjs made zombie-aware, to avoid operations on objs copied onto the clipboard , later deleted (upon closeproject's clipboardflush).
CVS User: zolmol
Index: MgaDumper.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Parser/MgaDumper.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** MgaDumper.cpp 13 Jan 2005 21:13:47 -0000 1.21
--- MgaDumper.cpp 20 Jan 2005 17:24:58 -0000 1.22
***************
*** 1471,1511 ****
}
void CMgaDumper::removeInnerObjs()
{
// try to remove those objects which are part of (child, grandchild) of another selected object
CComObjPtrVector<IMgaFCO>::iterator i = m_selFcos.begin();
while( i != m_selFcos.end())
{
! CComObjPtr<IMgaFCO> last_fco = *i, curr_fco = *i;
! bool found_parent = false;
! do
{
! CComObjPtr<IMgaModel> parent;
! COMTHROW( curr_fco->get_ParentModel(PutOut(parent)));
! last_fco = curr_fco;
! curr_fco = NULL;
! if (parent != NULL) {
! COMTHROW( ::QueryInterface(parent, curr_fco) );
! found_parent = std::find_if( m_selFcos.begin(), m_selFcos.end(), GmeEqual( curr_fco)) != m_selFcos.end();
! }
! } while ( curr_fco != NULL && !found_parent);
! if ( !found_parent) // no parent found in the set of fcos
{
! CComObjPtr<IMgaFolder> par_folder;
! COMTHROW( last_fco->get_ParentFolder(PutOut( par_folder)));
! while ( par_folder != NULL && !found_parent)
{
! found_parent = std::find_if( m_selFolders.begin(), m_selFolders.end(), GmeEqual( par_folder)) != m_selFolders.end();
! CComObjPtr<IMgaFolder> parent;
! COMTHROW( par_folder->get_ParentFolder(PutOut( parent)));
! par_folder = parent;
}
}
! if ( found_parent)
i = m_selFcos.erase( i);
else
--- 1471,1527 ----
}
+ //
+ // method called from the DumpFCO
+ // it is zombie-aware since it may happen that an object is placed to the clipboard
+ // then deleted, then the clipboard may be dumped when the project is closed
void CMgaDumper::removeInnerObjs()
{
+ bool zombies_found = false;
// try to remove those objects which are part of (child, grandchild) of another selected object
CComObjPtrVector<IMgaFCO>::iterator i = m_selFcos.begin();
while( i != m_selFcos.end())
{
! bool zombie = false;
! long status;
! COMTHROW( (*i)->get_Status(&status));
! if (status != OBJECT_EXISTS)
{
! zombies_found = zombie = true;
! }
! bool found_parent = false;
! if( !zombie)
{
! CComObjPtr<IMgaFCO> last_fco = *i, curr_fco = *i;
! do
! {
! CComObjPtr<IMgaModel> parent;
! COMTHROW( curr_fco->get_ParentModel(PutOut(parent)));
! last_fco = curr_fco;
! curr_fco = NULL;
! if (parent != NULL) {
! COMTHROW( ::QueryInterface(parent, curr_fco) );
! found_parent = std::find_if( m_selFcos.begin(), m_selFcos.end(), GmeEqual( curr_fco)) != m_selFcos.end();
! }
! } while ( curr_fco != NULL && !found_parent);
! if ( !found_parent) // no parent found in the set of fcos
{
! CComObjPtr<IMgaFolder> par_folder;
! COMTHROW( last_fco->get_ParentFolder(PutOut( par_folder)));
! while ( par_folder != NULL && !found_parent)
! {
! found_parent = std::find_if( m_selFolders.begin(), m_selFolders.end(), GmeEqual( par_folder)) != m_selFolders.end();
! CComObjPtr<IMgaFolder> parent;
! COMTHROW( par_folder->get_ParentFolder(PutOut( parent)));
!
! par_folder = parent;
! }
}
}
! if ( found_parent || zombie)
i = m_selFcos.erase( i);
else
***************
*** 1518,1535 ****
while( k != m_selFolders.end())
{
! CComObjPtr<IMgaFolder> par_folder;
! COMTHROW( (*k)->get_ParentFolder(PutOut( par_folder)));
bool found_parent = false;
!
! while ( par_folder != NULL && !found_parent)
{
! found_parent = std::find_if( m_selFolders.begin(), m_selFolders.end(), GmeEqual( par_folder)) != m_selFolders.end();
! CComObjPtr<IMgaFolder> parent;
! COMTHROW(par_folder->get_ParentFolder(PutOut( parent)));
! par_folder = parent;
}
! if ( found_parent)
k = m_selFolders.erase( k);
else
--- 1534,1562 ----
while( k != m_selFolders.end())
{
! bool zombie = false;
! long status;
! COMTHROW( (*k)->get_Status(&status));
! if (status != OBJECT_EXISTS)
! {
! zombies_found = zombie = true;
! }
!
bool found_parent = false;
! if( !zombie)
{
! CComObjPtr<IMgaFolder> par_folder;
! COMTHROW( (*k)->get_ParentFolder(PutOut( par_folder)));
!
! while ( par_folder != NULL && !found_parent)
! {
! found_parent = std::find_if( m_selFolders.begin(), m_selFolders.end(), GmeEqual( par_folder)) != m_selFolders.end();
! CComObjPtr<IMgaFolder> parent;
! COMTHROW(par_folder->get_ParentFolder(PutOut( parent)));
! par_folder = parent;
! }
}
! if ( found_parent || zombie)
k = m_selFolders.erase( k);
else
***************
*** 1537,1541 ****
}
! ASSERT( m_selFolders.size() + m_selFcos.size());
}
--- 1564,1568 ----
}
! ASSERT( zombies_found || m_selFolders.size() + m_selFcos.size() > 0);
}
More information about the GME-commit
mailing list