Skip to content

Fix folder browser code#9866

Merged
JeremyKuhne merged 1 commit intodotnet:release/8.0from
JeremyKuhne:fixfolderbrowser
Sep 8, 2023
Merged

Fix folder browser code#9866
JeremyKuhne merged 1 commit intodotnet:release/8.0from
JeremyKuhne:fixfolderbrowser

Conversation

@JeremyKuhne
Copy link
Copy Markdown
Member

@JeremyKuhne JeremyKuhne commented Sep 7, 2023

The old style folder browser was broken a few different ways:

  • FolderBrowserDialog would mutate the managed result string, usually corrupting memory in terrible ways
  • FolderNameEditor would AV
  • All were leaking shell handles

This adds a centralized helper to avoid these problems. This also:

  • Moves the exception string to primitives
  • Uses CSIDL defines and clarifies usage
  • Unblocks other CSIDL values
  • Uses the updated API to get the path from the PIDL

We can't use the shared dialog in FolderNameEditor as we expose dialog styles there that are not exposed in FolderBrowserDialog.

Fixes #9859

The old style folder browser was broken a few different ways:

- FolderBrowserDialog would not return the result
- FolderNameEditor would AV
- All were leaking shell handles

This adds a centralized helper to avoid these problems. This also:

- Moves the exception string to primitives
- Uses CSIDL defines and clarifies usage
- Unblocks other CSIDL values
- Uses the updated API to get the path from the PIDL

We can't use the shared dialog in FolderNameEditor as we expose dialog styles there that are not exposed in FolderBrowserDialog.

Fixes dotnet#9859
@JeremyKuhne JeremyKuhne requested a review from a team as a code owner September 7, 2023 22:40
@ghost ghost assigned JeremyKuhne Sep 7, 2023
@JeremyKuhne
Copy link
Copy Markdown
Member Author

Manually validated

@JeremyKuhne
Copy link
Copy Markdown
Member Author

I'm going to cherry pick this back to main as there are conflicts.

Copy link
Copy Markdown
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@Tanya-Solyanik
Copy link
Copy Markdown
Contributor

Tanya-Solyanik commented Sep 7, 2023

Where was the AV?
Here?

                    PWSTR selectedPath = default;
                    PInvoke.SHGetPathFromIDList(browseHandle, selectedPath);

@JeremyKuhne
Copy link
Copy Markdown
Member Author

Where was the AV?

@Tanya-Solyanik Yes, there. We were also pinning string.Empty and writing to it in the other dialog. 😲

@JeremyKuhne JeremyKuhne merged commit 7f91971 into dotnet:release/8.0 Sep 8, 2023
JeremyKuhne added a commit to JeremyKuhne/winforms that referenced this pull request Sep 8, 2023
The old style folder browser was broken a few different ways:

- FolderBrowserDialog would not return the result
- FolderNameEditor would AV
- All were leaking shell handles

This adds a centralized helper to avoid these problems. This also:

- Moves the exception string to primitives
- Uses CSIDL defines and clarifies usage
- Unblocks other CSIDL values
- Uses the updated API to get the path from the PIDL

We can't use the shared dialog in FolderNameEditor as we expose dialog styles there that are not exposed in FolderBrowserDialog.

Fixes dotnet#9859
JeremyKuhne added a commit that referenced this pull request Sep 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants