Skip to content

Commit c66a239

Browse files
authored
Merge pull request #9268 from adamint/defv/adamint/revert-async-load-designer-changes
Revert async load changes
2 parents e895c35 + edf0089 commit c66a239

File tree

4 files changed

+37
-28
lines changed

4 files changed

+37
-28
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/DesignerFramework/DesignerWindowPaneProviderBase.vb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
8888
_host = DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
8989
If _host IsNot Nothing AndAlso Not _host.Loading Then
9090
PopulateView()
91-
EnableUndo()
9291
End If
9392

9493
AddHandler surface.Loaded, AddressOf OnLoaded
@@ -139,7 +138,6 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
139138
'
140139
If _view IsNot Nothing AndAlso _view.Controls.Count = 0 Then
141140
PopulateView()
142-
EnableUndo()
143141
End If
144142
Return _view
145143
End Get
@@ -239,6 +237,10 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework
239237
Protected Overrides Sub OnCreate()
240238
MyBase.OnCreate()
241239

240+
_host = DirectCast(GetService(GetType(IDesignerHost)), IDesignerHost)
241+
If _host IsNot Nothing AndAlso Not _host.Loading Then
242+
EnableUndo()
243+
End If
242244
End Sub
243245

244246
''' <summary>

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: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
3838
' Contains information about the current state of Find/Replace
3939
Private ReadOnly _findReplace As New FindReplace(Me)
4040

41+
' Indicates whether or not we are trying to register our view helper on a delayed basis
42+
Private _delayRegisteringViewHelper As Boolean
43+
4144
' The ErrorListProvider to support error list window
4245
Private _errorListProvider As ErrorListProvider
4346

@@ -407,12 +410,34 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
407410
''' Register this root designer as a view helper with the current frame so the shell will can find our
408411
''' implementations of IVsFindTarget, IOleCommandTarget, etc.
409412
''' </summary>
410-
Public Sub RegisterViewHelper(VsWindowFrame As IVsWindowFrame)
413+
Public Sub RegisterViewHelper()
411414
Try
415+
Dim VsWindowFrame As IVsWindowFrame = CType(GetService(GetType(IVsWindowFrame)), IVsWindowFrame)
416+
412417
If VsWindowFrame IsNot Nothing Then
413418
VSErrorHandler.ThrowOnFailure(VsWindowFrame.SetProperty(__VSFPROPID.VSFPROPID_ViewHelper, New UnknownWrapper(Me)))
414419
Else
415-
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
416441
End If
417442
Catch ex As Exception When ReportWithoutCrash(ex, NameOf(RegisterViewHelper), NameOf(ResourceEditorRootDesigner))
418443
End Try

0 commit comments

Comments
 (0)