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() {
|
WaylandIntegration *WaylandIntegration::Instance() {
|
||||||
if (!::Platform::IsWayland()) return nullptr;
|
if (!::Platform::IsWayland()) return nullptr;
|
||||||
static std::optional<WaylandIntegration> instance(std::in_place);
|
static std::optional<WaylandIntegration> instance(std::in_place);
|
||||||
base::qt_signal_producer(
|
[[maybe_unused]] static const auto Inited = [] {
|
||||||
QGuiApplication::platformNativeInterface(),
|
base::qt_signal_producer(
|
||||||
&QObject::destroyed
|
QGuiApplication::platformNativeInterface(),
|
||||||
) | rpl::start_with_next([&] {
|
&QObject::destroyed
|
||||||
instance = std::nullopt;
|
) | rpl::start_with_next([] {
|
||||||
}, instance->_private->lifetime);
|
instance = std::nullopt;
|
||||||
|
}, instance->_private->lifetime);
|
||||||
|
return true;
|
||||||
|
}();
|
||||||
if (!instance) return nullptr;
|
if (!instance) return nullptr;
|
||||||
return &*instance;
|
return &*instance;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue