diff options
author | Alan McGovern <alan.mcgovern@gmail.com> | 2016-07-06 11:43:09 +0300 |
---|---|---|
committer | Alan McGovern <alan.mcgovern@gmail.com> | 2016-07-06 11:43:09 +0300 |
commit | bf423d15c65edcd454a68e6323ab62578816939b (patch) | |
tree | bb09e8486a4c38be41dc91377ca8bf8bde9c10ac /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop | |
parent | 5c411d138c999c580b7b284d3ff379fd0007c124 (diff) |
Revert "[Ide] Optimize RecentFiles updates."
This reverts commit 4153a8ee6492bc8957efc151f0f2e22e175df75b.
This re-introduced the race condition that was fixed in commit
e4998e0e4. Matt says:
"It is that union bit in OnRecentFilesChanged which is breaking
the previous fix."
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop')
3 files changed, 13 insertions, 120 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentFileStorage.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentFileStorage.cs index 906a1a1b08..b31007c063 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentFileStorage.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentFileStorage.cs @@ -347,46 +347,21 @@ namespace MonoDevelop.Ide.Desktop { return fileName.StartsWith ("file://") ? fileName : "file://" + fileName; } - - RecentItemUnionComparer comparer = new RecentItemUnionComparer (); + void OnRecentFilesChanged (List<RecentItem> list) { - string[] union; lock (cacheLock) { - union = cachedItemList - // Filter what changed only. - .Except (list, comparer) - .Concat (list.Except (cachedItemList, comparer)) - // Get the distinct groups - .SelectMany (it => it.Groups) - .Distinct () - .ToArray (); cachedItemList = list; } - if (union.Length > 0) { - Runtime.RunInMainThread (() => { - if (changed != null) - changed (this, new RecentItemsChangedEventArgs (union)); - }); - } - } - - class RecentItemUnionComparer : IEqualityComparer<RecentItem> - { - public bool Equals (RecentItem x, RecentItem y) - { - return x.Uri.Equals (y.Uri) && x.Timestamp.Equals (y.Timestamp); - } - - public int GetHashCode (RecentItem obj) - { - return obj.Uri.GetHashCode () ^ obj.Timestamp.GetHashCode (); - } + Runtime.RunInMainThread (() => { + if (changed != null) + changed (this, EventArgs.Empty); + }); } - - EventHandler<RecentItemsChangedEventArgs> changed; - public event EventHandler<RecentItemsChangedEventArgs> RecentFilesChanged { + + EventHandler changed; + public event EventHandler RecentFilesChanged { add { lock (this) { if (changed == null) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentItemsChangedEventArgs.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentItemsChangedEventArgs.cs deleted file mode 100644 index 754176154f..0000000000 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentItemsChangedEventArgs.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// RecentItemsChangedEventArgs.cs -// -// Author: -// therzok <marius.ungureanu@xamarin.com> -// -// Copyright (c) 2016 (c) Marius Ungureanu -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using System.Collections.Generic; - -namespace MonoDevelop.Ide.Desktop -{ - class RecentItemsChangedEventArgs : EventArgs - { - public IEnumerable<string> Groups { get; } - - public RecentItemsChangedEventArgs (IEnumerable<string> groups) - { - Groups = groups; - } - } -} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentOpen.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentOpen.cs index db49ba0f04..939b9dcd10 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentOpen.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/RecentOpen.cs @@ -54,47 +54,11 @@ namespace MonoDevelop.Ide.Desktop { recentFiles = new RecentFileStorage (storageFile); recentFiles.RemoveMissingFiles (fileGroup); - - recentFiles.RecentFilesChanged += OnRecentFilesChanged; } - - void OnRecentFilesChanged (object sender, RecentItemsChangedEventArgs args) - { - changed?.Invoke (sender, args); - if (args.Groups.Any (i => i.Contains (projGroup))) - projectsChanged?.Invoke (sender, args); - if (args.Groups.Any (i => i.Contains (fileGroup))) - filesChanged?.Invoke (sender, args); - } - - event EventHandler changed; + public override event EventHandler Changed { - add { - changed += value; - } - remove { - changed -= value; - } - } - - event EventHandler projectsChanged; - public override event EventHandler ProjectsChanged { - add { - projectsChanged += value; - } - remove { - projectsChanged -= value; - } - } - - event EventHandler filesChanged; - public override event EventHandler FilesChanged { - add { - filesChanged += value; - } - remove { - filesChanged -= value; - } + add { recentFiles.RecentFilesChanged += value; } + remove { recentFiles.RecentFilesChanged -= value; } } protected override IList<RecentFile> OnGetProjects () @@ -183,11 +147,8 @@ namespace MonoDevelop.Ide.Desktop public void Dispose () { - if (recentFiles != null) { - recentFiles.RecentFilesChanged -= OnRecentFilesChanged; - recentFiles.Dispose (); - recentFiles = null; - } + recentFiles.Dispose (); + recentFiles = null; } } @@ -235,9 +196,6 @@ namespace MonoDevelop.Ide.Desktop } public abstract event EventHandler Changed; - // TODO: Make these abstract for 7.0. - public virtual event EventHandler ProjectsChanged; - public virtual event EventHandler FilesChanged; public abstract void ClearProjects (); public abstract void ClearFiles (); public abstract void AddFile (string fileName, string displayName); |