protected virtual void ReallyDeleteReversalIndex(IReversalIndex ri) { try { Debug.Assert(ri.Hvo == m_list.OwningObject.Hvo); m_list.ListModificationInProgress = true; // can't reload deleted list! (LT-5353) // Clear out any virtual data stored in the cache for this reversal index. IVwCacheDa cda = m_cache.MainCacheAccessor as IVwCacheDa; IVwVirtualHandler vh = cda.GetVirtualHandlerName("LexSense", LexSenseReversalEntriesTextHandler.StandardFieldName); if (vh != null) { int wsDel = ri.WritingSystemRAHvo; IEnumerator <IReversalIndexEntry> erie = ri.EntriesOC.GetEnumerator(); while (erie.MoveNext()) { foreach (LinkedObjectInfo loi in erie.Current.BackReferences) { if (loi.RelObjClass == (int)LexSense.kClassId) { vh.Load(loi.RelObjId, vh.Tag, wsDel, cda); } } } } m_cache.BeginUndoTask(LexEdStrings.ksUndoDelete, LexEdStrings.ksRedoDelete); int cobjOld = m_cache.LangProject.LexDbOA.ReversalIndexesOC.Count; ri.DeleteUnderlyingObject(); int cobjNew; int hvoIdxNew = ReversalIndexAfterDeletion(m_cache, out cobjNew); m_cache.EndUndoTask(); SetReversalIndexHvo(hvoIdxNew); // Without this, switching to the ReversalEntries tool can crash if it was // displaying data from the deleted reversal entry. m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, m_cache.LangProject.LexDbOAHvo, (int)LexDb.LexDbTags.kflidReversalIndexes, 0, cobjNew, cobjOld); } finally { m_list.ListModificationInProgress = false; } // Can't do this until ListModificationInProgress flag is cleared because it // redisplays everything after reloading the list: if the list isn't actually // reloaded, it tries to display a deleted object -- CRASH! ChangeOwningObjectIfPossible(); // Without this, stale data can still display in the BulkEditSenses tool if you // recreate the deleted reversal index. m_mediator.SendMessage("MasterRefresh", null); }
protected virtual void ReallyDeleteReversalIndex(IReversalIndex ri) { try { Debug.Assert(ri.Hvo == m_list.OwningObject.Hvo); m_list.ListModificationInProgress = true; // can't reload deleted list! (LT-5353) // Clear out any virtual data stored in the cache for this reversal index. IVwCacheDa cda = m_cache.MainCacheAccessor as IVwCacheDa; IVwVirtualHandler vh = cda.GetVirtualHandlerName("LexSense", LexSenseReversalEntriesTextHandler.StandardFieldName); if (vh != null) { int wsDel = ri.WritingSystemRAHvo; IEnumerator<IReversalIndexEntry> erie = ri.EntriesOC.GetEnumerator(); while (erie.MoveNext()) { foreach (LinkedObjectInfo loi in erie.Current.BackReferences) { if (loi.RelObjClass == (int)LexSense.kClassId) vh.Load(loi.RelObjId, vh.Tag, wsDel, cda); } } } m_cache.BeginUndoTask(LexEdStrings.ksUndoDelete, LexEdStrings.ksRedoDelete); int cobjOld = m_cache.LangProject.LexDbOA.ReversalIndexesOC.Count; ri.DeleteUnderlyingObject(); int cobjNew; int hvoIdxNew = ReversalIndexAfterDeletion(m_cache, out cobjNew); m_cache.EndUndoTask(); SetReversalIndexHvo(hvoIdxNew); // Without this, switching to the ReversalEntries tool can crash if it was // displaying data from the deleted reversal entry. m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, m_cache.LangProject.LexDbOAHvo, (int)LexDb.LexDbTags.kflidReversalIndexes, 0, cobjNew, cobjOld); } finally { m_list.ListModificationInProgress = false; } // Can't do this until ListModificationInProgress flag is cleared because it // redisplays everything after reloading the list: if the list isn't actually // reloaded, it tries to display a deleted object -- CRASH! ChangeOwningObjectIfPossible(); // Without this, stale data can still display in the BulkEditSenses tool if you // recreate the deleted reversal index. m_mediator.SendMessage("MasterRefresh", null); }