Closed Boddlnagg closed 5 years ago
To statically prevent calling any WinRT functions without having initialized the runtime correctly (or after unintialization) is quite hard, if not impossible with current Rust. It would require adding a lifetime parameter to ComPtr
which binds the lifetime to a runtime context returned by the initialization function. However, adding a lifetime to ComPtr
is not easily possible, because it is used as associated type (RtType::Out
), such that some impls would have a lifetime parameters and some don't. I don't know if this is possible without HKT.
In #25 we panic now with an appropriate message if RoGetActivationFactory
is called without being correctly initialized. It is hard to get uninitialization wrong, but if one actually uninitializes while there are still WinRT objects alive, calling methods on them can lead to memory access violations, i.e. the thing that should not happen in safe Rust.
Closing in favor of #62, where the discussion has happened more recently.
In other words, provide wrappers for
RoInitialize
andRoUninitialize
and somehow ensure that the runtime is initialized before making other calls.