Skip to content

Commit

Permalink
Merge pull request #2766 from comintern/next
Browse files Browse the repository at this point in the history
Fix extreme UI sluggishness, avoid throws in SubclassingWindow.
  • Loading branch information
comintern committed Mar 2, 2017
2 parents 427ef60 + 0e8690b commit 243eb05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 9 additions & 5 deletions RetailCoder.VBE/UI/SelectionChangeService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Symbols;
using Rubberduck.VBEditor.Events;
Expand Down Expand Up @@ -39,8 +40,11 @@ private void OnVbeSelectionChanged(object sender, SelectionChangedEventArgs e)
return;
}

var eventArgs = new DeclarationChangedEventArgs(e.CodePane, _parser.State.FindSelectedDeclaration(e.CodePane));
DispatchSelectedDeclaration(eventArgs);
new Task(() =>
{
var eventArgs = new DeclarationChangedEventArgs(e.CodePane, _parser.State.FindSelectedDeclaration(e.CodePane));
DispatchSelectedDeclaration(eventArgs);
}).Start();
}

private void OnVbeFocusChanged(object sender, WindowChangedEventArgs e)
Expand All @@ -55,21 +59,21 @@ private void OnVbeFocusChanged(object sender, WindowChangedEventArgs e)
{
return;
}
DispatchSelectedDesignerDeclaration(_vbe.SelectedVBComponent);
new Task(() => DispatchSelectedDesignerDeclaration(_vbe.SelectedVBComponent)).Start();
break;
case WindowKind.CodeWindow:
//Caret changed in a code pane.
if (e.CodePane != null && !e.CodePane.IsWrappingNullReference)
{
DispatchSelectedDeclaration(new DeclarationChangedEventArgs(e.CodePane, _parser.State.FindSelectedDeclaration(e.CodePane)));
new Task(() => DispatchSelectedDeclaration(new DeclarationChangedEventArgs(e.CodePane, _parser.State.FindSelectedDeclaration(e.CodePane)))).Start();
}
break;
}
}
else if (e.EventType == FocusType.ChildFocus)
{
//Treeview selection changed in project window.
DispatchSelectedProjectNodeDeclaration(_vbe.SelectedVBComponent);
new Task(() => DispatchSelectedProjectNodeDeclaration(_vbe.SelectedVBComponent)).Start();
}
}

Expand Down
9 changes: 4 additions & 5 deletions Rubberduck.VBEEditor/WindowsApi/SubclassingWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected SubclassingWindow(IntPtr subclassId, IntPtr hWnd)
public void Dispose()
{
ReleaseHandle();
//GC.SuppressFinalize(this);
_thisHandle.Free();
}

private void AssignHandle()
Expand Down Expand Up @@ -86,14 +86,13 @@ public virtual int SubClassProc(IntPtr hWnd, IntPtr msg, IntPtr wParam, IntPtr l
{
if (!_listening)
{
throw new Exception("State corrupted. Received window message while not listening.");
Debug.WriteLine("State corrupted. Received window message while not listening.");
return DefSubclassProc(hWnd, msg, wParam, lParam);
}

Debug.Assert(IsWindow(_hwnd));
if ((uint)msg == (uint)WM.RUBBERDUCK_SINKING || (uint)msg == (uint)WM.DESTROY)
{
ReleaseHandle();
_thisHandle.Free();
ReleaseHandle();
}
return DefSubclassProc(hWnd, msg, wParam, lParam);
}
Expand Down

0 comments on commit 243eb05

Please sign in to comment.