Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LT-22018: Typing lost in example and translation fields #244

Open
wants to merge 1 commit into
base: release/9.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading