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 extreme UI sluggishness, avoid throws in SubclassingWindow. #2766

Merged
merged 4 commits into from Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions RetailCoder.VBE/UI/SelectionChangeService.cs
@@ -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
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