beeware / briefcase-windows-VisualStudio-template

A template for generating Visual Studio projects for building Windows apps with Briefcase
MIT License
4 stars 9 forks source link

Uninitialize the threading model during app startup. #11

Closed freakboy3742 closed 1 year ago

freakboy3742 commented 1 year ago

During app startup, there appears to be an implicit call to set the Winforms threading model. This causes problems on Qt, which makes it's own call to set the threading model as part of app startup.

This adds a call to uninitialise the threading model at startup, ensuring that app-specific attempts to set the threading model won't cause a crash.

This doesn't appear to impact the operation of the Crash Dialog, or Toga's own Dialog behaviour (Toga sets STA mode during app startup). The sample program provided by beeware/briefcase#930 also appears to work.

Also cleans up some environment management code that was raising warnings about using "unsafe" versions of methods.

Huge thanks to @davidfokkema for the leg work leading to this PR.

This could/should be backported to 0.3.12; it will also require retagging the app-template repository.

Fixes beeware/briefcase#930.

PR Checklist:

davidfokkema commented 1 year ago

Works like a charm! 😃