Skip to content

[Peek] Fix ShellPreviewHandler Previewer #40111

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

Merged
merged 1 commit into from
Jun 19, 2025
Merged

Conversation

davidegiacometti
Copy link
Collaborator

@davidegiacometti davidegiacometti commented Jun 18, 2025

Summary of the Pull Request

CsWin32 0.3.183 broke preview through preview handlers in Peek.

Error in UpdatePreviewAsync, falling back to default previewer: Unable to cast COM object of type 'System.__ComObject' to class type 'System.IntPtr'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

Signature of CoGetClassObject changed for last argument from void* to object.

Thanks @AArnott 🙂

PR Checklist

  • Closes: #xxx
  • 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

Tested Preview of Office files in Peek.

@davidegiacometti davidegiacometti force-pushed the users/davidegiacometti/peek-fix branch from b21fc1a to 13b6561 Compare June 18, 2025 18:55

This comment has been minimized.

@davidegiacometti davidegiacometti self-assigned this Jun 18, 2025
@davidegiacometti davidegiacometti added this to the PowerToys 0.92 milestone Jun 18, 2025
@davidegiacometti davidegiacometti added Product-Peek Refers to Peek Powertoys In for .92 Needs-Review This Pull Request awaits the review of a maintainer. labels Jun 18, 2025
@yeelam-gordon yeelam-gordon requested a review from Copilot June 19, 2025 00:29
Copy link
Contributor

@Copilot 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 the preview functionality in Peek caused by the breaking change in CsWin32 0.3.183, which modified the signature of CoGetClassObject.

  • Updated CoGetClassObject call to use an out parameter of type object
  • Simplified the IClassFactory retrieval by direct casting
  • Validated with Office file previews in Peek
Comments suppressed due to low confidence (1)

src/modules/peek/Peek.FilePreviewer/Previewers/ShellPreviewHandlerPreviewer/ShellPreviewHandlerPreviewer.cs:101

  • Directly casting pFactory to IClassFactory assumes that the returned object from CoGetClassObject supports the IClassFactory interface. Consider adding a comment or validation to clarify this assumption.
                                factory = (IClassFactory)pFactory;

@yeelam-gordon yeelam-gordon requested a review from lei9444 June 19, 2025 00:29
Copy link
Contributor

@lei9444 lei9444 left a comment

Choose a reason for hiding this comment

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

Thank you for addressing this issue.

@lei9444 lei9444 merged commit cc14fc3 into main Jun 19, 2025
14 checks passed
yeelam-gordon pushed a commit that referenced this pull request Jun 20, 2025
<!-- 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

CsWin32 0.3.183 broke preview through preview handlers in Peek.

`Error in UpdatePreviewAsync, falling back to default previewer: Unable
to cast COM object of type 'System.__ComObject' to class type
'System.IntPtr'. Instances of types that represent COM components cannot
be cast to types that do not represent COM components; however they can
be cast to interfaces as long as the underlying COM component supports
QueryInterface calls for the IID of the interface.`

Signature of `CoGetClassObject` changed for last argument from `void*`
to `object`.

Thanks @AArnott 🙂 

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] **Closes:** #xxx
- [ ] **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

Tested Preview of Office files in Peek.
@davidegiacometti davidegiacometti deleted the users/davidegiacometti/peek-fix branch June 21, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In for .92 Needs-Review This Pull Request awaits the review of a maintainer. Product-Peek Refers to Peek Powertoys
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants