aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIkalco <[email protected]>2024-08-31 14:55:08 -0500
committerGitHub <[email protected]>2024-08-31 21:55:08 +0200
commita6315b0af4e417cf396649d9c5792d3c5420b713 (patch)
tree5c76af314da05841de017e2de7192fa1c5d117d6
parentcac59fefecaefe34be45e65713d54676444f88a2 (diff)
downloadHyprland-a6315b0af4e417cf396649d9c5792d3c5420b713.tar.gz
Hyprland-a6315b0af4e417cf396649d9c5792d3c5420b713.zip
core: fix crash on monitor removed with gammaControl (#7601)
* fix crash on monitor removed with gammaControl * Update GammaControl.cpp
-rw-r--r--src/protocols/GammaControl.cpp14
-rw-r--r--src/protocols/GammaControl.hpp2
2 files changed, 8 insertions, 8 deletions
diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp
index cb75a202..d7992981 100644
--- a/src/protocols/GammaControl.cpp
+++ b/src/protocols/GammaControl.cpp
@@ -17,7 +17,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
return;
}
- pMonitor = OUTPUTRES->monitor.get();
+ pMonitor = OUTPUTRES->monitor;
if (!pMonitor) {
LOGM(ERR, "No CMonitor");
@@ -103,7 +103,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
resource->sendGammaSize(gammaSize);
listeners.monitorDestroy = pMonitor->events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
- listeners.monitorDisconnect = pMonitor->events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
+ listeners.monitorDisconnect = pMonitor->events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); });
}
CGammaControl::~CGammaControl() {
@@ -119,7 +119,7 @@ bool CGammaControl::good() {
}
void CGammaControl::applyToMonitor() {
- if (!pMonitor)
+ if (!pMonitor || !pMonitor->output)
return; // ??
LOGM(LOG, "setting to monitor {}", pMonitor->szName);
@@ -136,16 +136,16 @@ void CGammaControl::applyToMonitor() {
pMonitor->output->state->setGammaLut({});
}
- g_pHyprRenderer->damageMonitor(pMonitor);
+ g_pHyprRenderer->damageMonitor(pMonitor.get());
}
CMonitor* CGammaControl::getMonitor() {
- return pMonitor;
+ return pMonitor ? pMonitor.get() : nullptr;
}
void CGammaControl::onMonitorDestroy() {
+ LOGM(LOG, "Destroying gamma control for {}", pMonitor->szName);
resource->sendFailed();
- pMonitor = nullptr;
}
CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@@ -187,4 +187,4 @@ void CGammaControlProtocol::applyGammaToState(CMonitor* pMonitor) {
g->applyToMonitor();
break;
}
-} \ No newline at end of file
+}
diff --git a/src/protocols/GammaControl.hpp b/src/protocols/GammaControl.hpp
index 963eea5c..bbdc0139 100644
--- a/src/protocols/GammaControl.hpp
+++ b/src/protocols/GammaControl.hpp
@@ -20,7 +20,7 @@ class CGammaControl {
private:
SP<CZwlrGammaControlV1> resource;
- CMonitor* pMonitor = nullptr;
+ WP<CMonitor> pMonitor;
size_t gammaSize = 0;
bool gammaTableSet = false;
std::vector<uint16_t> gammaTable; // [r,g,b]+