PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Refine the CmdPal launch and activation logic when opening a new app instance

Open lei9444 opened this issue 7 months ago • 0 comments

Summary of the Pull Request

This PR address https://github.com/microsoft/PowerToys/issues/39376

Key changes:

  1. Ensures RedirectActivationToAsync(args) is properly awaited using .GetAwaiter().GetResult() to preserve activation data.
  2. Uses DispatcherQueue.TryEnqueue to safely handle UI thread execution and avoid COMException during window activation.
  3. Addresses a race condition in Logger.InitializeLogger where multiple instances could trigger creation of unexpected log files. The root cause is that TextWriterTraceListener attempts to create a log file even if the target file is already in use, which results in a fallback file path prefixed with a GUID.

cmdpal

PR Checklist

  • [x] Closes: #39376
  • [ ] Communication: I've discussed this with core contributors already. If 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

lei9444 avatar May 12 '25 14:05 lei9444