Skip to content

Commit

Permalink
Word Export: prevent cross-thread exception
Browse files Browse the repository at this point in the history
Use InvokeRequired and Invoke to re-execute the TextForReal call.

Notes:
- XHTML export is also calling this from a different thread but we
were not seeing this error because the text string was the same
as the current value so no change was made.
- The exception was only happening when there were reversals
and it seemed to only/mostly happen in debug builds.

Change-Id: I469ebe030dd421e0b449c7bdc9213b29050c514a
  • Loading branch information
mark-sil committed Jan 14, 2025
1 parent 18ca069 commit d437524
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Src/Common/Controls/FwControls/StatusBarTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ public string TextForReal
{
CheckDisposed();

if (m_bar.InvokeRequired)
{
m_bar.Invoke((Action<string>)(s => this.TextForReal = s), value);
return;
}

m_text = value;
// But we still need to set the Text property to get autosizing to work.
this.Text = m_text;
Expand Down
2 changes: 1 addition & 1 deletion Src/xWorks/DictionaryExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void Dispose(bool disposing)
{
System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType() + " ******");
if (disposing && m_currentClerk != null && !m_currentClerk.IsDisposed)
m_currentClerk.ActivateUI(true, false);
m_currentClerk.ActivateUI(true);
}

~ClerkActivator()
Expand Down

0 comments on commit d437524

Please sign in to comment.