Skip to content

Commit 94abffc

Browse files
committed
Avoid race conditions in WPF bindings by postemptively retesting before allowing OnExecute to continue.
1 parent 2073155 commit 94abffc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Rubberduck.Core/UI/Command/ReparseCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ protected override bool EvaluateCanExecute(object parameter)
4646

4747
protected override void OnExecute(object parameter)
4848
{
49+
// WPF binds to EvaluateCanExecute asychronously, which means that in some instances the bound refresh control will
50+
// enable itself based on a "stale" ParserState. There's no easy way to test for race conditions inside WPF, so we
51+
// need to make this test again...
52+
if (!EvaluateCanExecute(parameter))
53+
{
54+
return;
55+
}
56+
4957
if (_settings.CompileBeforeParse)
5058
{
5159
if (!VerifyCompileOnDemand())

0 commit comments

Comments
 (0)