From d605412da2c3ef4e45bcac79c61b0e0f6c574de3 Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 19 Apr 2013 19:35:19 +0900 Subject: [PATCH] =?utf8?q?=E3=83=AD=E3=83=83=E3=82=AF=E5=AF=BE=E8=B1=A1?= =?utf8?q?=E3=82=92=E5=8E=B3=E5=AF=86=E3=81=AB=20GetCurTabPost()=E3=82=82?= =?utf8?q?=5FpostCache/=5FitemCacheIndex=E3=82=92=E4=BD=BF=E3=81=A3?= =?utf8?q?=E3=81=A6=E3=81=84=E3=82=8B=E3=81=AE=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween/Tween.cs | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index 21d25080..f4dd165b 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -1950,7 +1950,7 @@ namespace OpenTween private void MyList_SelectedIndexChanged(object sender, EventArgs e) { - if (_curList == null || _curList.SelectedIndices.Count != 1) return; + if (_curList == null || !_curList.Equals(sender) || _curList.SelectedIndices.Count != 1) return; _curItemIndex = _curList.SelectedIndices[0]; if (_curItemIndex > _curList.VirtualListSize - 1) return; @@ -3381,10 +3381,15 @@ namespace OpenTween private PostClass GetCurTabPost(int Index) { - if (_postCache != null && Index >= _itemCacheIndex && Index < _itemCacheIndex + _postCache.Length) - return _postCache[Index - _itemCacheIndex]; - else - return _statuses[_curTab.Text, Index]; + this.itemCacheLock.EnterReadLock(); + try + { + if (_postCache != null && Index >= _itemCacheIndex && Index < _itemCacheIndex + _postCache.Length) + return _postCache[Index - _itemCacheIndex]; + } + finally { this.itemCacheLock.ExitReadLock(); } + + return _statuses[_curTab.Text, Index]; } @@ -5110,18 +5115,20 @@ namespace OpenTween this.itemCacheLock.EnterUpgradeableReadLock(); try { - if (_itemCache != null && - e.StartIndex >= _itemCacheIndex && - e.EndIndex < _itemCacheIndex + _itemCache.Length && - _curList.Equals(sender)) + if (_curList.Equals(sender)) { - //If the newly requested cache is a subset of the old cache, - //no need to rebuild everything, so do nothing. - return; - } + if (_itemCache != null && + e.StartIndex >= _itemCacheIndex && + e.EndIndex < _itemCacheIndex + _itemCache.Length) + { + //If the newly requested cache is a subset of the old cache, + //no need to rebuild everything, so do nothing. + return; + } - //Now we need to rebuild the cache. - if (_curList.Equals(sender)) CreateCache(e.StartIndex, e.EndIndex); + //Now we need to rebuild the cache. + CreateCache(e.StartIndex, e.EndIndex); + } } finally { this.itemCacheLock.ExitUpgradeableReadLock(); } } @@ -5181,6 +5188,7 @@ namespace OpenTween { //キャッシュ要求が実データとずれるため(イベントの遅延?) _postCache = null; + _itemCacheIndex = -1; _itemCache = null; } finally { this.itemCacheLock.ExitWriteLock(); } @@ -9355,7 +9363,6 @@ namespace OpenTween _anchorPost = null; _anchorFlag = false; this.PurgeListViewItemCache(); - _itemCacheIndex = -1; _curItemIndex = -1; _curPost = null; } -- 2.11.0