output: avoid crashes when binding a defunct wl_output global

ref #6508
This commit is contained in:
Vaxry 2024-06-15 17:56:44 +02:00
parent 6c24dc0bb1
commit 77f44bfcab

View file

@ -9,6 +9,9 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, SP<CMonitor> pMoni
pClient = resource->client(); pClient = resource->client();
if (!monitor)
return;
resource->setOnDestroy([this](CWlOutput* r) { resource->setOnDestroy([this](CWlOutput* r) {
if (monitor && PROTO::outputs.contains(monitor->szName)) if (monitor && PROTO::outputs.contains(monitor->szName))
PROTO::outputs.at(monitor->szName)->destroyResource(this); PROTO::outputs.at(monitor->szName)->destroyResource(this);
@ -69,6 +72,9 @@ CWLOutputProtocol::CWLOutputProtocol(const wl_interface* iface, const int& ver,
} }
void CWLOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CWLOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
if (defunct)
Debug::log(WARN, "[wl_output] Binding a wl_output that's inert?? Possible client bug.");
const auto RESOURCE = m_vOutputs.emplace_back(makeShared<CWLOutputResource>(makeShared<CWlOutput>(client, ver, id), monitor.lock())); const auto RESOURCE = m_vOutputs.emplace_back(makeShared<CWLOutputResource>(makeShared<CWlOutput>(client, ver, id), monitor.lock()));
if (!RESOURCE->good()) { if (!RESOURCE->good()) {