OSDN Git Service

TabInformations.PostsをConcurrentDictionaryに変更 (thx @intbatt, @Linfiel!)
authorKimura Youichi <kim.upsilon@bucyou.net>
Sat, 22 Aug 2015 11:34:46 +0000 (20:34 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 22 Aug 2015 11:48:55 +0000 (20:48 +0900)
https://osdn.jp/ticket/browse.php?group_id=6526&tid=35409

OpenTween/Resources/ChangeLog.txt
OpenTween/StatusDictionary.cs

index b5a7b11..fcfb452 100644 (file)
@@ -8,6 +8,7 @@
  * FIX: ミュート設定されたユーザーIDの取得時に発生したエラーが正しく処理されない不具合を修正
  * FIX: UserStreamsから想定外のデータを受信した場合のエラーが正しく処理されない不具合を修正
  * FIX: “[”キーで返信先ツイートを表示する際に、ツイートの取得が完了するまでウィンドウが応答無しの状態になる不具合を修正
+ * FIX: “[”キーで返信先ツイートを表示するタイミングによってエラーが発生する場合がある不具合を修正 (thx @intbatt, @Linfiel!)
 
 ==== Ver 1.2.7(2015/08/11)
  * 一部環境で pic.twitter.com やプロフィール画像が表示されない現象が発生しています
index ea1524d..6a56b4b 100644 (file)
@@ -26,6 +26,7 @@
 // Boston, MA 02110-1301, USA.
 
 using System;
+using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
@@ -476,7 +477,7 @@ namespace OpenTween
     {
         //個別タブの情報をDictionaryで保持
         private Dictionary<string, TabClass> _tabs = new Dictionary<string, TabClass>();
-        private Dictionary<long, PostClass> _statuses = new Dictionary<long, PostClass>();
+        private ConcurrentDictionary<long, PostClass> _statuses = new ConcurrentDictionary<long, PostClass>();
         private List<long> _addedIds;
         private List<long> _deletedIds = new List<long>();
         private Dictionary<long, PostClass> _retweets = new Dictionary<long, PostClass>();
@@ -836,7 +837,9 @@ namespace OpenTween
                     if (tab.Contains(Id))
                         tab.Remove(Id);
                 }
-                if (_statuses.ContainsKey(Id)) _statuses.Remove(Id);
+
+                PostClass removedPost;
+                _statuses.TryRemove(Id, out removedPost);
             }
         }
 
@@ -1099,7 +1102,7 @@ namespace OpenTween
                             if (BlockIds.Contains(Item.UserId))
                                 return;
 
-                            _statuses.Add(Item.StatusId, Item);
+                            _statuses.TryAdd(Item.StatusId, Item);
                         }
                         if (Item.RetweetedId != null)
                         {
@@ -1400,7 +1403,11 @@ namespace OpenTween
                                 break;
                             }
                         }
-                        if (!Hit) _statuses.Remove(Id);
+                        if (!Hit)
+                        {
+                            PostClass removedPost;
+                            _statuses.TryRemove(Id, out removedPost);
+                        }
                     }
                 }
 
@@ -1511,7 +1518,7 @@ namespace OpenTween
             return tabNameTemp;
         }
 
-        public Dictionary<long, PostClass> Posts
+        public ConcurrentDictionary<long, PostClass> Posts
         {
             get
             {
@@ -1621,9 +1628,9 @@ namespace OpenTween
         public long SinceId { get; set; }
 
         [XmlIgnore]
-        public Dictionary<long, PostClass> Posts { get; private set; }
+        public ConcurrentDictionary<long, PostClass> Posts { get; private set; }
 
-        private Dictionary<long, PostClass> _innerPosts;
+        private ConcurrentDictionary<long, PostClass> _innerPosts;
 
         public PostClass[] GetTemporaryPosts()
         {
@@ -1655,7 +1662,7 @@ namespace OpenTween
 
         public TabClass()
         {
-            _innerPosts = new Dictionary<long, PostClass>();
+            _innerPosts = new ConcurrentDictionary<long, PostClass>();
             Posts = _innerPosts;
             SoundFile = "";
             TabName = "";
@@ -1836,7 +1843,7 @@ namespace OpenTween
         public void AddPostToInnerStorage(PostClass Post)
         {
             if (_innerPosts.ContainsKey(Post.StatusId)) return;
-            _innerPosts.Add(Post.StatusId, Post);
+            _innerPosts.TryAdd(Post.StatusId, Post);
             _tmpIds.Add(new TemporaryId(Post.StatusId, Post.IsRead));
         }
 
@@ -1867,7 +1874,10 @@ namespace OpenTween
             this.unreadIds.Remove(Id);
 
             if (this.IsInnerStorageTabType)
-                this._innerPosts.Remove(Id);
+            {
+                PostClass removedPost;
+                this._innerPosts.TryRemove(Id, out removedPost);
+            }
         }
 
         public bool UnreadManage { get; set; }