[commit] r2658 - trunk/GME/Search

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Thu Dec 8 13:31:43 CST 2016


Author: ksmyth
Date: Thu Dec  8 13:31:43 2016
New Revision: 2658

Log:
Fix crash in search when Search within Scope is selected after the selected object is deleted

Modified:
   trunk/GME/Search/SearchCtl.cpp
   trunk/GME/Search/SearchDlg.cpp
   trunk/GME/Search/SearchDlg.h

Modified: trunk/GME/Search/SearchCtl.cpp
==============================================================================
--- trunk/GME/Search/SearchCtl.cpp	Tue Nov  8 16:25:21 2016	(r2657)
+++ trunk/GME/Search/SearchCtl.cpp	Thu Dec  8 13:31:43 2016	(r2658)
@@ -380,23 +380,28 @@
 	if(event==GLOBALEVENT_COMMIT_TRANSACTION)
 	{
 		m_searchDlg.RemoveZombies();
+		RemoveZombies<IMgaObject, IMgaObjects>(m_MgaObjs);
 	}
 	else if(event==GLOBALEVENT_NOTIFICATION_READY)
 	{
 		m_searchDlg.RemoveZombies();
+		RemoveZombies<IMgaObject, IMgaObjects>(m_MgaObjs);
 	}
 
 	else if(event==GLOBALEVENT_ABORT_TRANSACTION)
 	{
 		m_searchDlg.RemoveAll();
+		RemoveZombies<IMgaObject, IMgaObjects>(m_MgaObjs);
 	}
 	else if(event==GLOBALEVENT_UNDO)
 	{
 		m_searchDlg.RemoveZombies();
+		RemoveZombies<IMgaObject, IMgaObjects>(m_MgaObjs);
 	}
 	else if(event==GLOBALEVENT_REDO)
 	{		
 		m_searchDlg.RemoveZombies();
+		RemoveZombies<IMgaObject, IMgaObjects>(m_MgaObjs);
 	}
 	m_inEventTransactionMode = false;
 }

Modified: trunk/GME/Search/SearchDlg.cpp
==============================================================================
--- trunk/GME/Search/SearchDlg.cpp	Tue Nov  8 16:25:21 2016	(r2657)
+++ trunk/GME/Search/SearchDlg.cpp	Thu Dec  8 13:31:43 2016	(r2658)
@@ -213,31 +213,13 @@
 // Must remove results belong to zombie objects
 void CSearchDlg::RemoveZombies()
 {
-    bool zombieFound = false;
 	if (results == NULL)
 		return;
 
     CSearchCtrl *TheCtrl = GetCtrl();
     TheCtrl->BeginTransaction();
 
-    long position = 1; //IMgaFCOs is 1-based
-    MGACOLL_ITERATE(IMgaFCO,results)
-    {
-        long oStatus;
-        COMTHROW(MGACOLL_ITER->get_Status(&oStatus));
-        if(oStatus != OBJECT_EXISTS)
-        {
-            COMTHROW(results->Remove(position));
-            //removing the zombie causes the next item to have the same position
-            //that the zombie just had, so don't advance the position counter
-            zombieFound = true;
-        }
-        else
-        {
-            position++;
-        }
-
-    }MGACOLL_ITERATE_END;
+	bool zombieFound = ::RemoveZombies<IMgaFCO, IMgaFCOs>(results);
 
     if(zombieFound) //only redraw if we had to remove a zombie
     {

Modified: trunk/GME/Search/SearchDlg.h
==============================================================================
--- trunk/GME/Search/SearchDlg.h	Tue Nov  8 16:25:21 2016	(r2657)
+++ trunk/GME/Search/SearchDlg.h	Thu Dec  8 13:31:43 2016	(r2658)
@@ -15,6 +15,34 @@
 // SearchDlg.h : header file
 //
 
+template<typename FCO, typename FCOs>
+bool RemoveZombies(CComPtr<FCOs>& results) {
+	if (results == nullptr)
+	{
+		return false;
+	}
+	bool zombieFound = false;
+	long position = 1; //IMgaFCOs is 1-based
+	MGACOLL_ITERATE(FCO, results)
+	{
+		long oStatus;
+		COMTHROW(MGACOLL_ITER->get_Status(&oStatus));
+		if (oStatus != OBJECT_EXISTS)
+		{
+			COMTHROW(results->Remove(position));
+			//removing the zombie causes the next item to have the same position
+			//that the zombie just had, so don't advance the position counter
+			zombieFound = true;
+		}
+		else
+		{
+			position++;
+		}
+
+	}MGACOLL_ITERATE_END;
+	return zombieFound;
+}
+
 /////////////////////////////////////////////////////////////////////////////
 // CSearchDlg dialog
 


More information about the gme-commit mailing list