diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2019-04-23 19:20:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-23 19:20:34 +0300 |
commit | edf65b978f966d55faf010a41528ebb3c62f99bb (patch) | |
tree | 7783f93d4cb8225867f3157de3099068aeaf7f48 /main/src | |
parent | d9bd0590d9e91861ae66be06bca9cd21f28cffda (diff) | |
parent | b6ca57efbf07410ee30155d4f3c740aab168b119 (diff) |
Merge pull request #610 from xamarin/fix-848830
Fix document loading issues
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs | 10 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/GtkShellDocumentViewItem.cs | 20 |
2 files changed, 19 insertions, 11 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs index f8e0834124..937609c7df 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentManager.cs @@ -294,16 +294,12 @@ namespace MonoDevelop.Ide.Gui.Documents if (result.Content != null) { Counters.OpenDocumentTimer.Trace ("Wrapping document"); - Document doc = result.Content.DocumentController.Document; + Document doc = result.Content; ScrollToRequestedCaretLocation (doc, info); - if (doc != null && info.Options.HasFlag (OpenDocumentOptions.BringToFront)) { - doc.RunWhenLoaded (() => { - if (doc.Window != null) - doc.Select (); - }); - } + if (doc != null && info.Options.HasFlag (OpenDocumentOptions.BringToFront)) + doc.Select (); return doc; } return null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/GtkShellDocumentViewItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/GtkShellDocumentViewItem.cs index 273d4985e6..5905dbaadf 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/GtkShellDocumentViewItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Shell/GtkShellDocumentViewItem.cs @@ -34,6 +34,7 @@ using System; using MonoDevelop.Components.Commands; using MonoDevelop.Components.AtkCocoaHelper; using Gdk; +using MonoDevelop.Core; namespace MonoDevelop.Ide.Gui.Shell { @@ -76,8 +77,12 @@ namespace MonoDevelop.Ide.Gui.Shell protected override void OnRealized () { base.OnRealized (); - Load ().Ignore (); - SubscribeWindowEvents (); + Application.Invoke ((s,a) => { + // Don't execute Load inside the OnRealized handler, since Load can trigger events or async continuations that + // can end having an effect on the current widget, and that may cause weird behaviors of GTK. + Load ().Ignore (); + SubscribeWindowEvents (); + }); } protected override void OnDestroyed () @@ -94,8 +99,15 @@ namespace MonoDevelop.Ide.Gui.Shell public Task Load (CancellationToken cancellationToken) { - if (loadTask == null) - loadTask = OnLoad (cancellationToken); + if (loadTask == null) { + var cs = new TaskCompletionSource<bool> (); + loadTask = cs.Task; + OnLoad (cancellationToken).ContinueWith (t => { + if (t.IsFaulted) + LoggingService.LogError ("View failed to load", t.Exception); + cs.SetResult (true); + }); + } return loadTask; } |