Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdaf7e8d

Browse files
committed
Improve UIA Provider Cleanup Logic for Virtual ListView Items
1 parente36dddd commitdaf7e8d

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

‎src/System.Windows.Forms/System/Windows/Forms/Controls/ListView/ListView.cs‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ public partial class ListView : Control
208208
// We cache the NewWidth supplied by the user and use it on HDN_ENDTRACK to set the final column width.
209209
privateint_newWidthForColumnWidthChangingCancelled=-1;
210210

211+
// Tracks ListViewItems that have had their AccessibilityObject created in virtual mode,
212+
// so their UIA providers can be properly released later without triggering item retrieval
213+
privatereadonlyHashSet<ListViewItem>_uiaCreatedItems=[];
214+
211215
/// <summary>
212216
/// Creates an empty ListView with default styles.
213217
/// </summary>
@@ -5084,16 +5088,43 @@ public void RedrawItems(int startIndex, int endIndex, bool invalidateOnly)
50845088
}
50855089
}
50865090

5091+
internalvoidNotifyUiaCreated(ListViewItemitem)
5092+
{
5093+
if(VirtualMode)
5094+
{
5095+
_uiaCreatedItems.Add(item);
5096+
}
5097+
}
5098+
50875099
internaloverridevoidReleaseUiaProvider(HWNDhandle)
50885100
{
50895101
if(!OsVersion.IsWindows8OrGreater())
50905102
{
50915103
return;
50925104
}
50935105

5094-
for(inti=0;i<Items.Count;i++)
5106+
if(VirtualMode)
50955107
{
5096-
Items.GetItemByIndex(i)?.ReleaseUiaProvider();
5108+
foreach(ListViewItemitemin_uiaCreatedItems)
5109+
{
5110+
if(item.IsAccessibilityObjectCreated)
5111+
{
5112+
item.ReleaseUiaProvider();
5113+
}
5114+
}
5115+
5116+
_uiaCreatedItems.Clear();
5117+
}
5118+
else
5119+
{
5120+
for(inti=0;i<Items.Count;i++)
5121+
{
5122+
varitem=Items.GetItemByIndex(i);
5123+
if(item?.IsAccessibilityObjectCreated==true)
5124+
{
5125+
item.ReleaseUiaProvider();
5126+
}
5127+
}
50975128
}
50985129

50995130
if(_defaultGroupis notnull)

‎src/System.Windows.Forms/System/Windows/Forms/Controls/ListView/ListViewItem.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,12 @@ internal virtual AccessibleObject AccessibilityObject
265265
};
266266
}
267267

268+
owningListView.NotifyUiaCreated(this);
268269
return_accessibilityObject;
269270
}
270271
}
271272

272-
privateboolIsAccessibilityObjectCreated=>_accessibilityObjectis notnull;
273+
internalboolIsAccessibilityObjectCreated=>_accessibilityObjectis notnull;
273274

274275
/// <summary>
275276
/// The font that this item will be displayed in. If its value is null, it will be displayed
@@ -1011,7 +1012,7 @@ internal void Host(ListView parent, int id, int index)
10111012

10121013
internalvoidReleaseUiaProvider()
10131014
{
1014-
if(!IsAccessibilityObjectCreated)
1015+
if(IsAccessibilityObjectCreated)
10151016
{
10161017
return;
10171018
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp