Ensure Wayland integration instance accessor doesn't leak
This commit is contained in:
parent
3749f10e7f
commit
8a56048801
1 changed files with 9 additions and 6 deletions
|
|
@ -68,12 +68,15 @@ WaylandIntegration::~WaylandIntegration() = default;
|
|||
WaylandIntegration *WaylandIntegration::Instance() {
|
||||
if (!::Platform::IsWayland()) return nullptr;
|
||||
static std::optional<WaylandIntegration> instance(std::in_place);
|
||||
[[maybe_unused]] static const auto Inited = [] {
|
||||
base::qt_signal_producer(
|
||||
QGuiApplication::platformNativeInterface(),
|
||||
&QObject::destroyed
|
||||
) | rpl::start_with_next([&] {
|
||||
) | rpl::start_with_next([] {
|
||||
instance = std::nullopt;
|
||||
}, instance->_private->lifetime);
|
||||
return true;
|
||||
}();
|
||||
if (!instance) return nullptr;
|
||||
return &*instance;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue