mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-19 06:09:49 +01:00
core: fix crash on monitor removed with gammaControl (#7601)
* fix crash on monitor removed with gammaControl * Update GammaControl.cpp
This commit is contained in:
parent
cac59fefec
commit
a6315b0af4
2 changed files with 8 additions and 8 deletions
|
@ -17,7 +17,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMonitor = OUTPUTRES->monitor.get();
|
pMonitor = OUTPUTRES->monitor;
|
||||||
|
|
||||||
if (!pMonitor) {
|
if (!pMonitor) {
|
||||||
LOGM(ERR, "No CMonitor");
|
LOGM(ERR, "No CMonitor");
|
||||||
|
@ -103,7 +103,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
|
||||||
resource->sendGammaSize(gammaSize);
|
resource->sendGammaSize(gammaSize);
|
||||||
|
|
||||||
listeners.monitorDestroy = pMonitor->events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
|
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() {
|
CGammaControl::~CGammaControl() {
|
||||||
|
@ -119,7 +119,7 @@ bool CGammaControl::good() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGammaControl::applyToMonitor() {
|
void CGammaControl::applyToMonitor() {
|
||||||
if (!pMonitor)
|
if (!pMonitor || !pMonitor->output)
|
||||||
return; // ??
|
return; // ??
|
||||||
|
|
||||||
LOGM(LOG, "setting to monitor {}", pMonitor->szName);
|
LOGM(LOG, "setting to monitor {}", pMonitor->szName);
|
||||||
|
@ -136,16 +136,16 @@ void CGammaControl::applyToMonitor() {
|
||||||
pMonitor->output->state->setGammaLut({});
|
pMonitor->output->state->setGammaLut({});
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pHyprRenderer->damageMonitor(pMonitor);
|
g_pHyprRenderer->damageMonitor(pMonitor.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMonitor* CGammaControl::getMonitor() {
|
CMonitor* CGammaControl::getMonitor() {
|
||||||
return pMonitor;
|
return pMonitor ? pMonitor.get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGammaControl::onMonitorDestroy() {
|
void CGammaControl::onMonitorDestroy() {
|
||||||
|
LOGM(LOG, "Destroying gamma control for {}", pMonitor->szName);
|
||||||
resource->sendFailed();
|
resource->sendFailed();
|
||||||
pMonitor = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ class CGammaControl {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SP<CZwlrGammaControlV1> resource;
|
SP<CZwlrGammaControlV1> resource;
|
||||||
CMonitor* pMonitor = nullptr;
|
WP<CMonitor> pMonitor;
|
||||||
size_t gammaSize = 0;
|
size_t gammaSize = 0;
|
||||||
bool gammaTableSet = false;
|
bool gammaTableSet = false;
|
||||||
std::vector<uint16_t> gammaTable; // [r,g,b]+
|
std::vector<uint16_t> gammaTable; // [r,g,b]+
|
||||||
|
|
Loading…
Reference in a new issue