Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPF control crash while using "Find" feature #22

Open
fadden opened this issue Jun 30, 2024 · 1 comment
Open

WPF control crash while using "Find" feature #22

fadden opened this issue Jun 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fadden
Copy link
Owner

fadden commented Jun 30, 2024

When finding files in the GUI, the application tries to scroll the window contents so that the found item is selected. It needs to do this in the file list and, for hierarchical filesystems, in the directory tree.

The application has a DirectoryTreeItem method called BringItemIntoView that took several hours and a couple of stackoverflow posts to figure out. It calls an internal VirtualizingPanel method called BringIndexIntoView. Most of the time this works, but sometimes it crashes like this:

 ---> System.InvalidOperationException: Cannot call StartAt when content generation is in progress.
   at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.StartAt(GeneratorPosition position, GeneratorDirection direction, Boolean allowStartAtRealizedItem)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverrideImpl(Size constraint, Nullable`1& lastPageSafeOffset, List`1& previouslyMeasuredOffsets, Nullable`1& lastPagePixelSize, Boolean remeasure)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
[...]
   at System.Windows.Controls.VirtualizingStackPanel.BringIndexIntoView(Int32 index)

The next Find operation blows up while trying to traverse the TreeView.

These failures can be ignored, since ultimately it just means that the directory tree isn't getting scrolled, but it's not ideal.

Reproduction steps:

  • Open devcdjan92.iso (an image of the January 1992 Apple Developer CD-ROM).
  • Hit Ctrl+F, type "gsbug", click "Find Next". That causes the first crash.
  • Click "Find Next". That causes the second failure.
  • Continuing to click "Find Next" works without issue, until you wrap around to the top again.

Unrelated but interesting: if you select an item in the file list in the middle of a large archive, and move the scrollbar elsewhere, sometimes the file view jumps back to the item if you move the directory tree scrollbar around. More weird interactions with virtualization?

@fadden fadden added the bug Something isn't working label Jun 30, 2024
fadden added a commit that referenced this issue Jun 30, 2024
Repositioning a virtualized WPF TreeView control is hard.  This
doesn't fix the underlying problem, but does prevent the application
from exploding.

(issue #22)
@fadden
Copy link
Owner Author

fadden commented Jul 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant