Skip to content

Commit 3279cbb

Browse files
committed
Revert "Register view helper when frame is shown"
This reverts commit c372e2b.
1 parent 0d351aa commit 3279cbb

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

src/Microsoft.VisualStudio.Editors/DesignerFramework/BaseDesignerLoader.vb

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -684,14 +684,6 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
684684
Protected Overridable Sub OnDesignerWindowActivated(Activated As Boolean)
685685
End Sub
686686

687-
''' <summary>
688-
''' Called before the frame that's hosting the designer is shown.
689-
''' </summary>
690-
''' <param name="FirstShow">Indicates whether this is the first time the designer is being shown.</param>
691-
''' <param name="Frame">The frame hosting the designer.</param>
692-
Protected Overridable Sub OnBeforeDesignerWindowShow(FirstShow As Boolean, Frame As IVsWindowFrame)
693-
End Sub
694-
695687
#End Region
696688

697689
''' <summary>
@@ -826,16 +818,6 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
826818
End If
827819
End Function
828820

829-
Private Function OnBeforeDocumentWindowShow(docCookie As UInteger, firstShow As Integer, frame As IVsWindowFrame) As Integer _
830-
Implements IVsRunningDocTableEvents.OnBeforeDocumentWindowShow, IVsRunningDocTableEvents2.OnBeforeDocumentWindowShow
831-
832-
' Only notify if our frame showing
833-
If CType(GetService(GetType(IVsWindowFrame)), IVsWindowFrame) Is frame Then
834-
OnBeforeDesignerWindowShow(firstShow = 1, frame)
835-
End If
836-
837-
End Function
838-
839821
#Region "RDT events we don't care about"
840822

841823
Private Function OnAfterAttributeChange(docCookie As UInteger, attributes As UInteger) As Integer _
@@ -858,6 +840,10 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
858840
Implements IVsRunningDocTableEvents.OnAfterSave, IVsRunningDocTableEvents2.OnAfterSave
859841
End Function
860842

843+
Private Function OnBeforeDocumentWindowShow(docCookie As UInteger, firstShow As Integer, frame As IVsWindowFrame) As Integer _
844+
Implements IVsRunningDocTableEvents.OnBeforeDocumentWindowShow, IVsRunningDocTableEvents2.OnBeforeDocumentWindowShow
845+
End Function
846+
861847
#End Region
862848
#End Region
863849

src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorDesignerLoader.vb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
141141
'Try to restore the editor state from before the last reload, if any.
142142
NewResourceEditorRoot.RootDesigner.TryDepersistSavedEditorState()
143143

144+
'Now that we know the load succeeded, we can try registering our view helper
145+
NewResourceEditorRoot.RootDesigner.RegisterViewHelper()
144146
Catch ex As Exception When ReportWithoutCrash(ex, NameOf(HandleLoad), NameOf(ResourceEditorDesignerLoader))
145147
_rootComponent = Nothing
146148

@@ -256,12 +258,6 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
256258
End If
257259
End Sub
258260

259-
Protected Overrides Sub OnBeforeDesignerWindowShow(FirstShow As Boolean, Frame As IVsWindowFrame)
260-
If FirstShow Then
261-
_rootComponent.RootDesigner.RegisterViewHelper(Frame)
262-
End If
263-
End Sub
264-
265261
''' <summary>
266262
''' ManualCheckOut without the ProjectReloaded flag because it is not needed in
267263
''' the resource editor.

src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorRootDesigner.vb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,34 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
410410
''' Register this root designer as a view helper with the current frame so the shell will can find our
411411
''' implementations of IVsFindTarget, IOleCommandTarget, etc.
412412
''' </summary>
413-
Public Sub RegisterViewHelper(VsWindowFrame As IVsWindowFrame)
413+
Public Sub RegisterViewHelper()
414414
Try
415+
Dim VsWindowFrame As IVsWindowFrame = CType(GetService(GetType(IVsWindowFrame)), IVsWindowFrame)
416+
415417
If VsWindowFrame IsNot Nothing Then
416418
VSErrorHandler.ThrowOnFailure(VsWindowFrame.SetProperty(__VSFPROPID.VSFPROPID_ViewHelper, New UnknownWrapper(Me)))
417419
Else
418-
Debug.Fail("Unable to register our view helper")
420+
If _view IsNot Nothing Then
421+
'We don't have a window frame yet. Need to delay this registration until we do.
422+
' Easiest way is to use BeginInvoke.
423+
If _delayRegisteringViewHelper Then
424+
'This is already our second try
425+
Debug.Fail("Unable to delay-register our view helper")
426+
_delayRegisteringViewHelper = False
427+
Else
428+
'Try again, delayed.
429+
_delayRegisteringViewHelper = True
430+
431+
' VS Whidbey #260046 -- Make sure the control is created before calling Invoke/BeginInvoke
432+
If _view.Created = False Then
433+
_view.CreateControl()
434+
End If
435+
436+
_view.BeginInvoke(New System.Windows.Forms.MethodInvoker(AddressOf RegisterViewHelper))
437+
End If
438+
Else
439+
Debug.Fail("View not set in RegisterViewHelper() - can't delay-register view helper")
440+
End If
419441
End If
420442
Catch ex As Exception When ReportWithoutCrash(ex, NameOf(RegisterViewHelper), NameOf(ResourceEditorRootDesigner))
421443
End Try

0 commit comments

Comments
 (0)