Skip to content

Commit

Permalink
Fix LT-22018: Typing lost in example and translation fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmaxwell3 authored and jasonleenaylor committed Jan 2, 2025
1 parent 900f5de commit 2d933ef
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
20 changes: 18 additions & 2 deletions Src/Common/Controls/DetailControls/DataTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public class DataTree : UserControl, IVwNotifyChange, IxCoreColleague, IRefresha
bool m_fDoNotRefresh = false;
bool m_fPostponedClearAllSlices = false;
// Set during ConstructSlices, to suppress certain behaviors not safe at this point.
bool m_postponePropChanged = true;
internal bool ConstructingSlices { get; private set; }

public List<Slice> Slices { get; private set; }
Expand Down Expand Up @@ -527,6 +528,15 @@ public LcmStyleSheet StyleSheet

}

public virtual bool OnPostponePropChanged(object commandObject)
{
if ((bool)commandObject == true)
m_postponePropChanged = true;
else
m_postponePropChanged = false;
return true;
}

public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
{
CheckDisposed();
Expand Down Expand Up @@ -557,7 +567,13 @@ public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
// because some slice data structures that are being used by the invoker
// get disposed by RefreshList (LT-21980, LT-22011). So we postpone calling
// RefreshList until the work is done.
this.BeginInvoke(new Action(PostponedRefreshList));
if (m_postponePropChanged)
{
this.BeginInvoke(new Action(RefreshListAndFocus));
} else
{
RefreshListAndFocus();
}
}
// Note, in LinguaLinks import we don't have an action handler when we hit this.
else if (m_cache.DomainDataByFlid.GetActionHandler() != null && m_cache.DomainDataByFlid.GetActionHandler().IsUndoOrRedoInProgress)
Expand All @@ -584,7 +600,7 @@ public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
}
}

private void PostponedRefreshList()
private void RefreshListAndFocus()
{
if (!IsDisposed)
{
Expand Down
14 changes: 13 additions & 1 deletion Src/Common/Controls/DetailControls/GhostStringSlice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,19 @@ private void SwitchToReal()
// Make the real object and set the string property we are ghosting. The final PropChanged
// will typically dispose this and create a new string slice whose key is our own key
// followed by the flid of the string property.
int hvoNewObj = MakeRealObject(tssTyped);
// To avoid problems, PropChanged must not be postponed (cf. LT-22018).
// Copy m_mediator in case 'this' gets disposed.
Mediator mediator = m_mediator;
int hvoNewObj;
try
{
mediator.SendMessage("PostponePropChanged", false);
hvoNewObj = MakeRealObject(tssTyped);
}
finally
{
mediator.SendMessage("PostponePropChanged", true);
}

// Now try to make a suitable selection in the slice that replaces this.
RestoreSelection(ich, datatree, parentKey, hvoNewObj, flidStringProp, wsToCreate);
Expand Down

0 comments on commit 2d933ef

Please sign in to comment.