Skip to content

Fix Advanced Paste crash issue#45207

Merged
vanzue merged 1 commit intomainfrom
shawn/fixAPCrash
Feb 5, 2026
Merged

Fix Advanced Paste crash issue#45207
vanzue merged 1 commit intomainfrom
shawn/fixAPCrash

Conversation

@shuaiyuanxx
Copy link
Copy Markdown
Contributor

@shuaiyuanxx shuaiyuanxx commented Jan 30, 2026

Summary of the Pull Request

This pull request refactors the AdvancedPasteAdditionalActions class to use private backing fields and custom property accessors for its action properties. This change allows for better control over property initialization and ensures that the properties always have valid, non-null default values.

Refactoring for property initialization and null safety:

  • Introduced private backing fields (_imageToText, _pasteAsFile, _transcode) for the ImageToText, PasteAsFile, and Transcode properties in AdvancedPasteAdditionalActions, replacing auto-properties.
  • Updated the property accessors for ImageToText, PasteAsFile, and Transcode to use the new backing fields and ensure that a new default instance is assigned if a null value is provided during initialization.

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@shuaiyuanxx shuaiyuanxx marked this pull request as ready for review January 30, 2026 01:25
@shuaiyuanxx shuaiyuanxx changed the title fix ap crash issue Fix Advanced Paste crash issue Jan 30, 2026
@github-actions
Copy link
Copy Markdown

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

Unrecognized words (1)

Metacharacter

These words are not needed and should be removed ROOTOWNER

Some files were automatically ignored 🙈

These sample patterns would exclude them:

^src/modules/powerrename/unittests/testdata/avif_test\.avif$
^src/modules/powerrename/unittests/testdata/heif_test\.heic$

You should consider adding them to:

.github/actions/spell-check/excludes.txt

File matching is via Perl regular expressions.

To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.

To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:microsoft/PowerToys.git repository
on the shawn/fixAPCrash branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/21501000344/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Warnings ⚠️ (1)

See the 📂 files view, the 📜action log, or 📝 job summary for details.

⚠️ Warnings Count
⚠️ large-file 2

See ⚠️ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a crash issue (#45189) in the Advanced Paste settings page by refactoring the AdvancedPasteAdditionalActions class to use private backing fields with null-safe init accessors. The change ensures that properties are never null, even if null values are provided during JSON deserialization.

Changes:

  • Added private backing fields for ImageToText, PasteAsFile, and Transcode properties
  • Converted auto-properties to explicit properties with custom init accessors that use null-coalescing operator

@vanzue vanzue merged commit d9a1c35 into main Feb 5, 2026
20 of 21 checks passed
@vanzue vanzue deleted the shawn/fixAPCrash branch February 5, 2026 02:36
vanzue pushed a commit that referenced this pull request Feb 5, 2026
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This pull request refactors the `AdvancedPasteAdditionalActions` class
to use private backing fields and custom property accessors for its
action properties. This change allows for better control over property
initialization and ensures that the properties always have valid,
non-null default values.

**Refactoring for property initialization and null safety:**

* Introduced private backing fields (`_imageToText`, `_pasteAsFile`,
`_transcode`) for the `ImageToText`, `PasteAsFile`, and `Transcode`
properties in `AdvancedPasteAdditionalActions`, replacing
auto-properties.
* Updated the property accessors for `ImageToText`, `PasteAsFile`, and
`Transcode` to use the new backing fields and ensure that a new default
instance is assigned if a null value is provided during initialization.
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #45189
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
@vanzue vanzue added this to the PowerToys 0.97 milestone Feb 9, 2026
@vanzue vanzue added the Product-Advanced Paste Refers to the Advanced Paste module label Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Advanced Paste Refers to the Advanced Paste module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings Main page crashes when trying to select settings for advanced paste

4 participants