Skip to content

Commit

Permalink
output/xdg-output: avoid sending events to released globals
Browse files Browse the repository at this point in the history
ref #6835
  • Loading branch information
vaxerski committed Oct 8, 2024
1 parent ac65850 commit bc29992
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/protocols/XDGOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32
#endif
pXDGOutput->client = CLIENT;

pXDGOutput->outputProto = OUTPUT->owner;

if (!pXDGOutput->resource->resource()) {
m_vXDGOutputs.pop_back();
mgr->noMemory();
Expand Down Expand Up @@ -104,7 +106,7 @@ CXDGOutput::CXDGOutput(SP<CZxdgOutputV1> resource_, SP<CMonitor> monitor_) : mon
void CXDGOutput::sendDetails() {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");

if (!monitor)
if (!monitor || !outputProto || outputProto->isDefunct())
return;

const auto POS = isXWayland ? monitor->vecXWaylandPosition : monitor->vecPosition;
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/XDGOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class CMonitor;
class CXDGOutputProtocol;
class CWLOutputProtocol;

class CXDGOutput {
public:
Expand All @@ -16,6 +17,7 @@ class CXDGOutput {
private:
WP<CMonitor> monitor;
SP<CZxdgOutputV1> resource;
WP<CWLOutputProtocol> outputProto;

std::optional<Vector2D> overridePosition;

Expand Down
5 changes: 4 additions & 1 deletion src/protocols/core/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SP<CWlOutput> CWLOutputResource::getResource() {
}

void CWLOutputResource::updateState() {
if (!monitor || (owner && owner->defunct))
if (!monitor || !owner || owner->defunct)
return;

if (resource->version() >= 2)
Expand Down Expand Up @@ -119,6 +119,9 @@ bool CWLOutputProtocol::isDefunct() {
}

void CWLOutputProtocol::sendDone() {
if (defunct)
return;

for (auto const& r : m_vOutputs) {
r->resource->sendDone();
}
Expand Down

0 comments on commit bc29992

Please sign in to comment.