Skip to content

Commit 02eabc4

Browse files
committed
Fix deadlock when coming out of suspension on the UI thread in Ready state
On the change to Ready state, the CE dispatches work to the UI thread and waits for the completion. If the change was triggered from the UI thread, this causes a deadlock. Usually, such a change only happens during parsing, which is executed on a background thread. However, when coming out of parser suspension, it can happen as well. To deal with this, the state changed action now also checks that the old state was not Busy.
1 parent 5d3fb28 commit 02eabc4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Rubberduck.UI.Command;
1414
using Rubberduck.VBEditor.SafeComWrappers;
1515
using System.Windows;
16+
using System.Windows.Forms;
1617
using System.Windows.Input;
1718
using Rubberduck.Parsing.UIContext;
1819
using Rubberduck.Templates;
@@ -229,10 +230,11 @@ private void HandleStateChanged(object sender, ParserStateEventArgs e)
229230
{
230231
Unparsed = false;
231232

232-
if (e.State == ParserState.Ready)
233+
if (e.State == ParserState.Ready && e.OldState != ParserState.Busy)
233234
{
234235
// Finished up resolving references, so we can now update the reference nodes.
235236
//We have to wait for the task to guarantee that no new parse starts invalidating all cached components.
237+
//CAUTION: This must not be executed from the UI thread!!!
236238
_uiDispatcher.StartTask(() =>
237239
{
238240
var referenceFolders = Projects.SelectMany(node =>

0 commit comments

Comments
 (0)